This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Gloom and despair. Can't link any STL objects (gcc 4.2.2 on AIX 5.2)


This has to be something really trivial but I can't identify the cause.
I've been trying to get a simple link to work for over a month.

I have a minimal Hello World! program .

#include <iostream>

using namespace std;

int main()
{
   cout << "Hello, world!" << endl;
   return 0;
}

When I compile and link this thing I get a few undefined symbols, including
std::cout and std::endl.  I used nm to generate a listing of the symbols in
the program and in libstdc++.a and found exact matches in libstc++.a for all
symbols marked U in the hello world program.

hw.o

$ nm -C hw.o | less
000000b0 T .global destructors keyed to main
00000100 T .global constructors keyed to main
00000000 t .__static_initialization_and_destruction_0(int, int)
         U .std::ios_base::Init::Init()
         U .std::ios_base::Init::~Init()
         U .std::basic_ostream<char, std::char_traits<char> >&
std::__ostream_in
sert<char, std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<ch
ar> >&, char const*, long)
         U .std::basic_ostream<char, std::char_traits<char> >&
std::endl<char, s
td::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)
000001f8 d .data
00000150 T .main
00000000 t .text
00000294 d LANCHOR..0
0000028c d TOC
000001d4 D global destructors keyed to main
000001d4 d global destructors keyed to main
000001f8 D _GLOBAL__F_main_EA2494C7
000001e0 d global constructors keyed to main
000001e0 D global constructors keyed to main
000001c8 d __static_initialization_and_destruction_0(int, int)
         U std::cout
00000290 d std::cout
0000028c d std::__ioinit
         U __gxx_personality_v0
00000298 b _hw.bss_
000001b8 t _hw.rw_
000001ec D main
000001ec d main

libstdc++.a

200256e4 d std::cout
20005488 D std::cout

10067318 T .std::ios_base::Init::Init()
1005efac t .std::ios_base::Init::~Init()
1005efac T .std::ios_base::Init::~Init()
1005f088 t .std::ios_base::Init::~Init()
1005f088 T .std::ios_base::Init::~Init()

1005a36c t .std::basic_ostream<char, std::char_traits<char> >&
std::__ostream_in
sert<char, std::char_traits<char> >(std::basic_ostream<char,
std::char_traits<ch
ar> >&, char const*, long)

I whall spare you the remainder.  Meanwhile here is the verbose
compile-and-link output so you can see how the compiler was built.

$ g++ -v -O -o hw hw.cpp
Using built-in specs.
Target: powerpc-ibm-aix5.2.0.0
Configured with: /home.local/jsaxton/gcc-4.2.2/configure
--enable-version-specific-runtime-libs --enable-static --enable-shared
--enable-threads --with-as=/usr/linux/bin/as --without-gnu-ld
--with-ld=/usr/bin/ld --prefix=/opt/freeware --disable-nls --with-pic
--disable-symvers --enable-symvers=no --enable-languages=c,c++
Thread model: aix
gcc version 4.2.2
 /opt/freeware/libexec/gcc/powerpc-ibm-aix5.2.0.0/4.2.2/cc1plus -quiet -v
-D_ALL_SOURCE hw.cpp -quiet -dumpbase hw.cpp -auxbase hw -O -version -o
/tmp//ccghUISD.s
ignoring nonexistent directory
"/opt/freeware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.2/../../../../powerpc-ibm-
aix5.2.0.0/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/freeware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.2/include/c++
 
/opt/freeware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.2/include/c++/powerpc-ibm-a
ix5.2.0.0
 /opt/freeware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.2/include/c++/backward
 /usr/local/include
 /opt/freeware/include
 /opt/freeware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.2/include
 /usr/include
End of search list.
GNU C++ version 4.2.2 (powerpc-ibm-aix5.2.0.0)
        compiled by GNU C version 4.2.2.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=32768
Compiler executable checksum: b3280b25fd192f7d327adc641c139763
 /usr/linux/bin/as -u -mppc -o /tmp//ccTYQ4BV.o /tmp//ccghUISD.s
 /opt/freeware/libexec/gcc/powerpc-ibm-aix5.2.0.0/4.2.2/collect2
-bpT:0x10000000 -bpD:0x20000000 -btextro -bnodelcsect -o hw /lib/crt0.o
-L/opt/freeware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.2
-L/opt/freeware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.2
-L/opt/freeware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.2/../../../../powerpc-ibm
-aix5.2.0.0/lib
-L/opt/freeware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.2/../../..
/tmp//ccTYQ4BV.o -lstdc++ -lm -lgcc_s
/opt/freeware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.2/libgcc.a -lc -lgcc_s
/opt/freeware/lib/gcc/powerpc-ibm-aix5.2.0.0/4.2.2/libgcc.a
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: std::cout
ld: 0711-317 ERROR: Undefined symbol: .std::basic_ostream<char,
std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char>
>(std::basic_ostream<char, std::char_traits<char> >&, char const*, long)
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: __gxx_personality_v0
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
information.
collect2: ld returned 8 exit status

The compiler was built following instructions posted by Thomas Mittelstaedt
at the end of January.  I did not assume root privilege to build the
compiler, just to install it.

There is no old version of g++, ld, as, libstdc++.a, bind, bind64, etc on
the system.

I have run out of ideas.  I don't even know where to look.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]