Dear LJ Genie: I am in linker hell

May 22, 2009 18:57

I'm building a C++ project for an unusual platform, and am having some confusing problems with my libstdc++. For some reason which I cannot fathom, I am getting an absurd number of "undefined reference to..." linker errors for symbols which are indeed undefined in libstdc++.a, but which are definitely defined in libc.a and libgcc.a. Yes, I am ( Read more... )

lj genie, code, busy busy busy

Leave a comment

Comments 20

moof May 23 2009, 20:56:07 UTC
What are you using for your link command, anyway? If you're doing g++ -o foo foo.o, it should automatically generate the proper -lstdc++ et al; you shouldn't have to specify them yourself. to wit:

pts/3 dogcow@shiny: /tmp 3545 % g++ -v -o foo foo.o
Using built-in specs.
Target: i386--netbsdelf
Configured with: /usr/src/tools/gcc/../../gnu/dist/gcc4/configure --enable-long-long --disable-multilib --enable-threads --disable-symvers --build=x86_64-unknown-netbsd4.99.72 --host=i386--netbsdelf --target=i386--netbsdelf --enable-__cxa_atexit
Thread model: posix
gcc version 4.1.3 20080704 prerelease (NetBSD nb2 20081120)
ld -dc -dp -e __start -dynamic-linker /usr/libexec/ld.elf_so -o foo /usr/lib/crt0.o /usr/lib/crti.o /usr/lib/crtbegin.o foo.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/crtend.o /usr/lib/crtn.o

I suppose it's possible that gcc is attempting to be clever by noticing that you specified -lstdc++ yourself, and should thus not link anything else....

Reply

maradydd May 23 2009, 22:31:31 UTC
Nope, it flipped the hell out about not being able to find various C++ symbols when libstdc++ wasn't included. This is an autotools project with about a dozen source files; strangely, regular old g++ doesn't need me to specify libstdc++, libc, libgcc or anything like that, but arm-elf-g++ needs its hand held.

Reply

moof May 24 2009, 09:18:25 UTC
Ah. In that case, the xcompiler isn't fully targeted with all the necessary scary magic. Bah.

Reply


Leave a comment

Up