bellinghman: (Default)
[personal profile] bellinghman
I have a problem trying to link some C++ code on AIX 5.3:



I'm trying to create a shared library on AIX, containing both the source to Perl, and some C++ code. I've got the relevant parts compiling, but I'm ending up with a link failure. This is what the output looks like. I'm obviously missing some library, but I'm rather bemused as to what, since I've never played on AIX before, and have hardly ever used gcc either.

(Yes, I'm logged in as root - so sue me. I'm running as the only user, and it's a throwaway environment.)

[pS0468C:root] /aix_gcc $ dmake
Linking Release/libJavaPerl.so
gcc -L/usr/lib/threads -shared -o Release/libJavaPerl.so -Wl,-brtl -Wl,-bdynamic -Wl,-bmaxdata:0x80000000 -Wl,-b32 -Xlinker Rel_tmp/PerlInterface.o Rel_tmp/com_episys_javaperl_Interpreter.o Rel_tmp/JavaAdaptor.o Rel_tmp/EvalReturn.o Rel_tmp/BadParameters.o Rel_tmp/Callback.o Rel_tmp/CharSetConverter.o Rel_tmp/PerlException.o Rel_tmp/JavaObjectRef.o Rel_tmp/JStringToUTF8.o Rel_tmp/StackTrace.o Rel_tmp/UTF8ToJString.o Rel_tmp/libperl.a Rel_tmp/DynaLoader.a -lbind -lnsl -ldl -lld -lm -lcrypt -lpthreads -lc -lbsd -lstdc++
ld: 0711-317 ERROR: Undefined symbol: vtable for __cxxabiv1::__vmi_class_type_info
ld: 0711-317 ERROR: Undefined symbol: vtable for __cxxabiv1::__class_type_info
ld: 0711-317 ERROR: Undefined symbol: vtable for __cxxabiv1::__si_class_type_info
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string
[Error: Irreparable invalid markup ('<char,>') in entry. Owner must fix manually. Raw contents below.]

I have a problem trying to link some C++ code on AIX 5.3:

<lj-cut text="definitely behind a cut">

I'm trying to create a shared library on AIX, containing both the source to Perl, and some C++ code. I've got the relevant parts compiling, but I'm ending up with a link failure. This is what the output looks like. I'm obviously missing some library, but I'm rather bemused as to what, since I've never played on AIX before, and have hardly ever used gcc either.

(Yes, I'm logged in as root - so sue me. I'm running as the only user, and it's a throwaway environment.)

[pS0468C:root] /aix_gcc $ dmake
Linking Release/libJavaPerl.so
gcc -L/usr/lib/threads -shared -o Release/libJavaPerl.so -Wl,-brtl -Wl,-bdynamic -Wl,-bmaxdata:0x80000000 -Wl,-b32 -Xlinker Rel_tmp/PerlInterface.o Rel_tmp/com_episys_javaperl_Interpreter.o Rel_tmp/JavaAdaptor.o Rel_tmp/EvalReturn.o Rel_tmp/BadParameters.o Rel_tmp/Callback.o Rel_tmp/CharSetConverter.o Rel_tmp/PerlException.o Rel_tmp/JavaObjectRef.o Rel_tmp/JStringToUTF8.o Rel_tmp/StackTrace.o Rel_tmp/UTF8ToJString.o Rel_tmp/libperl.a Rel_tmp/DynaLoader.a -lbind -lnsl -ldl -lld -lm -lcrypt -lpthreads -lc -lbsd -lstdc++
ld: 0711-317 ERROR: Undefined symbol: vtable for __cxxabiv1::__vmi_class_type_info
ld: 0711-317 ERROR: Undefined symbol: vtable for __cxxabiv1::__class_type_info
ld: 0711-317 ERROR: Undefined symbol: vtable for __cxxabiv1::__si_class_type_info
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::~basic_string()
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::operator=(std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> > const&)
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::basic_string(std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> > const&)
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::basic_string()
ld: 0711-317 ERROR: Undefined symbol: .std::allocator<char>::allocator()
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&)
ld: 0711-317 ERROR: Undefined symbol: .std::basic_istringstream<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::basic_istringstream(std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> > const&, std::_Ios_Openmode)
ld: 0711-317 ERROR: Undefined symbol: .std::allocator<char>::~allocator()
ld: 0711-317 ERROR: Undefined symbol: .std::basic_istream<char, std::char_traits<char="std::char_traits&lt;char"> >::operator>>(void*&)
ld: 0711-317 ERROR: Undefined symbol: .std::basic_istringstream<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::~basic_istringstream()
ld: 0711-317 ERROR: Undefined symbol: typeinfo for std::exception
ld: 0711-317 ERROR: Undefined symbol: vtable for std::exception
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::c_str() const
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::compare(std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> > const&) const
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::size() const
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::append(std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> > const&)
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::append(char const*)
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::operator+=(char const*)
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::find(std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> > const&, unsigned long) const
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::erase(unsigned long, unsigned long)
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::begin()
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::operator[](unsigned long)
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::operator=(char const*)
ld: 0711-317 ERROR: Undefined symbol: .std::basic_ostringstream<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::basic_ostringstream(std::_Ios_Openmode)
ld: 0711-317 ERROR: Undefined symbol: .std::basic_ostream<char, std::char_traits<char="std::char_traits&lt;char"> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char="std::char_traits&lt;char"> >&, char const*)
ld: 0711-317 ERROR: Undefined symbol: .std::basic_ostream<char, std::char_traits<char="std::char_traits&lt;char"> >::operator<<(void const*)
ld: 0711-317 ERROR: Undefined symbol: .std::basic_ostringstream<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::str() const
ld: 0711-317 ERROR: Undefined symbol: .std::basic_ostringstream<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::~basic_ostringstream()
ld: 0711-317 ERROR: Undefined symbol: .std::allocator<wchar_t>::allocator()
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<wchar_t, std::char_traits<wchar_t="std::char_traits&lt;wchar_t">, std::allocator<wchar_t> >::basic_string(unsigned long, wchar_t, std::allocator<wchar_t> const&)
ld: 0711-317 ERROR: Undefined symbol: .std::allocator<wchar_t>::~allocator()
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<wchar_t, std::char_traits<wchar_t="std::char_traits&lt;wchar_t">, std::allocator<wchar_t> >::operator[](unsigned long)
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::operator[](unsigned long) const
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<wchar_t, std::char_traits<wchar_t="std::char_traits&lt;wchar_t">, std::allocator<wchar_t> >::~basic_string()
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<wchar_t, std::char_traits<wchar_t="std::char_traits&lt;wchar_t">, std::allocator<wchar_t> >::size() const
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::basic_string(unsigned long, char, std::allocator<char> const&)
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<wchar_t, std::char_traits<wchar_t="std::char_traits&lt;wchar_t">, std::allocator<wchar_t> >::operator[](unsigned long) const
ld: 0711-317 ERROR: Undefined symbol: .std::basic_ostream<char, std::char_traits<char="std::char_traits&lt;char"> >& std::operator<< <char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >(std::basic_ostream<char, std::char_traits<char="std::char_traits&lt;char"> >&, std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> > const&)
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<wchar_t, std::char_traits<wchar_t="std::char_traits&lt;wchar_t">, std::allocator<wchar_t> >::c_str() const
ld: 0711-317 ERROR: Undefined symbol: .std::allocator<wchar_t>::~allocator()
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<wchar_t, std::char_traits<wchar_t="std::char_traits&lt;wchar_t">, std::allocator<wchar_t> >::_S_empty_rep()
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<wchar_t, std::char_traits<wchar_t="std::char_traits&lt;wchar_t">, std::allocator<wchar_t> >::_Rep::_M_refdata()
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<wchar_t, std::char_traits<wchar_t="std::char_traits&lt;wchar_t">, std::allocator<wchar_t> >::_Rep::_S_create(unsigned long, unsigned long, std::allocator<wchar_t> const&)
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<wchar_t, std::char_traits<wchar_t="std::char_traits&lt;wchar_t">, std::allocator<wchar_t> >::_Rep::_M_set_length_and_sharable(unsigned long)
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<wchar_t, std::char_traits<wchar_t="std::char_traits&lt;wchar_t">, std::allocator<wchar_t> >::_Alloc_hider::_Alloc_hider(wchar_t*, std::allocator<wchar_t> const&)
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<wchar_t, std::char_traits<wchar_t="std::char_traits&lt;wchar_t">, std::allocator<wchar_t> >::basic_string()
ld: 0711-317 ERROR: Undefined symbol: .std::allocator<char>::~allocator()
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::_S_empty_rep()
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::_Rep::_M_refdata()
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&)
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::_S_copy_chars(char*, char const*, char const*)
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::_Rep::_M_destroy(std::allocator<char> const&)
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::_Rep::_M_set_length_and_sharable(unsigned long)
ld: 0711-317 ERROR: Undefined symbol: .std::basic_string<char, std::char_traits<char="std::char_traits&lt;char">, std::allocator<char> >::_Alloc_hider::_Alloc_hider(char*, std::allocator<char> const&)
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: ld returned 8 exit status
dmake: Error code 1, while making 'Release/libJavaPerl.so'


[pS0468C:root] /aix_gcc $ gcc --v
Using built-in specs.
Target: powerpc-ibm-aix5.3.0.0
Configured with: ../configure --with-as=/usr/bin/as --with-ld=/usr/bin/ld --disable-nls --enable-languages=c,c++ --prefix=/opt/freeware --enable-threads --enable-version-specific-runtime-libs --host=powerpc-ibm-aix5.3.0.0
Thread model: aix
gcc version 4.0.0

</lj-cut>

Any clues?

Date: 2007-07-27 05:57 pm (UTC)
ext_8103: (Default)
From: [identity profile] ewx.livejournal.com

I'm puzzled as to why you're decorating the first object file with -Xlinker. I'm not convinced it should make much difference but still.

Try linking with g++ instead of gcc.

They all look like symbols I would expect to be in GNU libstdc++, so I'd try to identify which library of that name the linker is finding.

We use the native compiler on AIX so I don't know much about GCC on AIX.

try to identify

Date: 2007-07-27 06:00 pm (UTC)
ext_8103: (Default)
From: [identity profile] ewx.livejournal.com
For instance by truss -o output.txt -f gcc blahblahblah

Re: try to identify

Date: 2007-07-30 09:45 am (UTC)
From: [identity profile] bellinghman.livejournal.com
I know not of this 'truss' ypu speak of.

(Actually, a quick 'man truss' leaves me wondering which process it might be useful to look at.)

As for the -Xlinker option - removing that makes no difference. (It was there because the gcc build for Perl used it. But that doesn't include any C++. And isn't a shared library. Hmmm.)

Re: try to identify

Date: 2007-07-30 11:08 am (UTC)
ext_8103: (Default)
From: [identity profile] ewx.livejournal.com
Someone seems to have posted the right answer below. But truss reports all the system calls made by a process or processes; the suggested command line (i.e. with all the gcc options replacing blahblahblah) will trace the driver and all its descendants, i.e. everything that could possibly be involved.

Re: try to identify

Date: 2007-07-30 11:18 am (UTC)
From: [identity profile] bellinghman.livejournal.com
Ah, I see.

I'm currently compiling and linking with xlc - and it's almost worrying that the linker completes almost before the command lines is displayed. I'm not sure whether that's the symptom of doing something wrong, or I've been deeply damaged by how long Windows linkers take on PCs.

Re: try to identify

Date: 2007-08-05 04:03 pm (UTC)
ext_8103: (Default)
From: [identity profile] ewx.livejournal.com
I don't usually do interactive builds on AIX so I can't really comment there. My experience from Linux with GNU LD is that the linker consumes a great deal of memory and that if you don't have enough RAM it swaps like mad; but with adequate RAM it's not dreadfully slow.

Re: try to identify

Date: 2007-08-05 05:47 pm (UTC)
From: [identity profile] bellinghman.livejournal.com
It's just insanely fast, is all. The code is linking and running fine now.

Date: 2007-07-27 11:23 pm (UTC)
From: [identity profile] erikvolson.livejournal.com
Thread model: aix
gcc version 4.0.0


Known bug in gcc 4.0. Current is 4.2.1. Try that (at least patch to the latest 4.0.X...) or see if it builds with xlc.

Shared libs in AIX are odd. If you say with gcc, you should read this.

http://www.ibm.com/developerworks/aix/library/au-gnu.html

Date: 2007-07-30 10:41 pm (UTC)
From: [identity profile] bellinghman.livejournal.com
Hmm, yes. I'd been pointed at that already.

I've now rebuilt using cc_r, and the result seems to link. But when loaded by Java, any call that causes C++ to allocate memory causes a core dump.

Oddly, 'malloc()' doesn't - but 'new int()' does.

What I really need is an example, fully statically-linked shared lib. I assume IBM has one somewhere, but I'm somewhat without docs.

Date: 2007-07-31 11:32 am (UTC)
From: [identity profile] bellinghman.livejournal.com
mKay ... damned stupid linker. I thought I told you I want everything resolved. Oh, you thought you'd finish the job at runtime?

May 2016

S M T W T F S
1234 567
891011121314
15 1617 18192021
22232425262728
293031    

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Sep. 13th, 2025 10:29 pm
Powered by Dreamwidth Studios