tags:

views:

531

answers:

2

I am trying to build a 64 bit binary from C++ code using 32bit g++ compiler. I am getting the following errors while building:

=============================================================================
=> /usr/local/bin/g++ -shared -maix64 -fPIC -Wl,-bM:SRE -Wl,-bnoentry -Wl,-bE:gcc_shr_lib.so.exp -o gcc_shr_lib.so gcc_shr_lib.o -L/usr/local/lib
ld: 0711-319 WARNING: Exported symbol not defined: gcc_whereAmI
ld: 0711-317 ERROR: Undefined symbol: typeinfo for std::bad_alloc
ld: 0711-317 ERROR: Undefined symbol: __gxx_personality_v0
ld: 0711-317 ERROR: Undefined symbol: vtable for std::exception
ld: 0711-317 ERROR: Undefined symbol: vtable for std::bad_alloc
ld: 0711-317 ERROR: Undefined symbol: .std::ios_base::Init::Init()
ld: 0711-317 ERROR: Undefined symbol: .std::ios_base::Init::~Init()
ld: 0711-317 ERROR: Undefined symbol: .operator new(unsigned long)
ld: 0711-317 ERROR: Undefined symbol: .operator delete(void*)
ld: 0711-317 ERROR: Undefined symbol: ._Unwind_Resume
ld: 0711-317 ERROR: Undefined symbol: .__cxa_get_exception_ptr
ld: 0711-317 ERROR: Undefined symbol: .__cxa_begin_catch
ld: 0711-317 ERROR: Undefined symbol: std::cout
ld: 0711-317 ERROR: Undefined symbol: .std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
ld: 0711-317 ERROR: Undefined symbol: std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)
ld: 0711-317 ERROR: Undefined symbol: .std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))
ld: 0711-317 ERROR: Undefined symbol: .std::bad_alloc::~bad_alloc()
ld: 0711-317 ERROR: Undefined symbol: .__cxa_end_catch
ld: 0711-317 ERROR: Undefined symbol: .__register_frame_info_table
ld: 0711-317 ERROR: Undefined symbol: .__deregister_frame_info
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: ld returned 8 exit status

=============================================================================

It seems I need 64bit libstdc++ available on my build system. Could you please throw some light to solve this.

Q1) Is it ok to build 64 bit binaries using 32 bit g++ compiler on AIX 5.2

Q2) Where should I get 64 bit libstdc++? Will this 64 bit libstdc++ work with 32bit g++ compiler?

A: 

You seem to be building a shared library rather than an executable.

As long as the relevant 64-bit libraries are available on the machine, it should not matter whether your G++ is itself a 32-bit or a 64-bit binary - it should be able to generate both 32-bit and 64-bit object files (and shared libraries, and executables, etc).

Be aware that GCC (or G++) uses a different name-mangling scheme from other compilers quite deliberately - because it does various things (such as exception handling, class layouts and the like) differently from other compilers. You cannot reliably link code compiled with the native XLC compilers with code compiled with G++. However, you do not seem to be doing that here.

You should look under /usr/local/lib to see what you can find in the way of 64-bit C++ libraries; you may need to mention the right directory and shared library name on the command line. Alternatively, add the '-v' flag to the command and see what is actually being executed.

You seem to just have missing symbols; you don't have mismatched 32-bit vs 64-bit object files or libraries or whatever. So, you're close - just not quite there yet.

(Is AIX 5.2 still supported? Shouldn't you be planning to move to 5.3 or 6.1?)

Jonathan Leffler
A: 

Hi Jonathan,

Thanks a lot for your quick response and pointing the problem.

Following are the versions of GCC/G++ i am using:

============================================= => gcc -v Using built-in specs. Target: powerpc-ibm-aix5.2.0.0 Configured with: ../gcc-4.1.1/configure --disable-aix64 --disable-nls Thread model: aix gcc version 4.1.1 [tsivaram@maroon /] => g++ -v Using built-in specs. Target: powerpc-ibm-aix5.2.0.0 Configured with: ../gcc-4.1.1/configure --disable-aix64 --disable-nls Thread model: aix gcc version 4.1.1

=============================================

Since gcc and g++ are configured/built with "--disable-aix64", there are no 64 bit STD libraries available (Ex: libstdc++).

AIX version i am using: => uname -a AIX maroon 2 5 000663FC4C00 [tsivaram@maroon /] => oslevel 5.2.0.0 [tsivaram@maroon /] => oslevel -r 5200-05

How can i build 64bit libstdc++ which should work with gcc/g++ 4.1.1.

Do i need to rebuild GCC and G++ without "--disable-aix64" flag? if yes, could you please point to me a link how to build.

Can not we just build libstdc++ library (required)?

Thanks a lot in advance, Thumbeti

Thumbeti
It is better if you reply to Jonathan's answer with "add comment", so they are keep together.
Ismael