bellinghman: (Default)
bellinghman ([personal profile] bellinghman) wrote2007-07-27 06:40 pm

A question on AIX/gcc/C++

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?

Re: try to identify

[identity profile] bellinghman.livejournal.com 2007-07-30 09:45 am (UTC)(link)
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.)
ext_8103: (Default)

Re: try to identify

[identity profile] ewx.livejournal.com 2007-07-30 11:08 am (UTC)(link)
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

[identity profile] bellinghman.livejournal.com 2007-07-30 11:18 am (UTC)(link)
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.
ext_8103: (Default)

Re: try to identify

[identity profile] ewx.livejournal.com 2007-08-05 04:03 pm (UTC)(link)
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

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