I\'m trying to build a program against wxWidgets, and I get a linker error. I\'d like to really understand what it means. The error is:
/usr/lib/libwx_baseu-2.8.
I thought that .so files had all its symbols resolved, contrary to .o files that still need linking.
Shared libraries can be incomplete, that is OK.
do you know how I can get a list on undefined symbols in an ELF file
Use
nm -C -u libwx_baseu-2.8.so
I think you don't link to some of the libraries when linking your program.
You should link in your program to all shared libraries you link to in your .so
If the .so is linked to some static libraries - it's not required in the program to link to them if all needed symbols are found in the .so
You may use nm
linux command to see the symbols in object file, library or binary
Edit
Your particular problem can be described here: http://old.nabble.com/-Bug-49433--gcc4.4,-NEW:-gcc4.4-misses-std::endl-implementation-at--O2%2B-td22836171.html
When you link a shared library against other shared libraries (e.g. link libwx_baseu-2.8.so
against libstdc++.so
), the linker records versioned symbols used by libwx_baseu
and provided by libstdc++
.
If at runtime you use a different copy of libstdc++
(one which doesn't provide the same versioned symbol(s)), you get a (dynamic) liking error and the program doesn't run at all (this is preferable to a "mystery" crash later on).
But what's happening here is that you try to link an executable, which means the (static) linker wants to find all symbols which will be required at runtime. Again, you are linking the executable against a different (older) libstdc++.so
, and so the linking fails.
There are two usual root causes:
- either you linked libwx_baseu-2.8.so
on a different system (one with newer version of GCC), and copied it to the current system, or
- you've linked libwx_baseu-2.8.so
with a newer GCC on the same system, but now are trying to link the executable with an older GCC.
Try : putting -fno-inline in your flags in Makefile. Basically g++4.4 is having issues without it. Try to put it OR remove the -O option. It solved the same problem I had.