Search code examples
c++shared-librariesstatic-librariesundefined-symbol

Undefined symbol in static lib linked into dynamic library


here is my issue:

At runtime my program which load shared library fail to load one, it says:

libCommunicationModule.so: undefined symbol __builtin_delete

the context:

  • compiler: gcc 3.4
  • Linux Debian 4.0 (old stuff ....)

I have a static library: libtgi_cppd.a , I don't have the source of this library. This lib is linked into the shared library libCommunicationModule.so with these options -Wl,-whole-archive -ltgi_cppd

I enabled -y option on __builtin_delete to check:

libtgi_cppd.a(ClientAPI_cpp.o): reference to __builtin_delete
libtgi_cppd.a(ClientInterface.o): reference to __builtin_delete
libtgi_cppd.a(ClientAPI_cpp.o): reference to __builtin_delete

I try to add to link command -lstdc++ -lgcc before and after -whole-archive, no change.

$ nm libCommunicationModule.so | grep __builtin

result is always like this:

     U __builtin_delete
     U __builtin_new
     U __builtin_vec_new

What can I do to solve this issue?

Thank you

Full command as requiered:

g++ -Wl,-y -Wl,__builtin_delete -Wl,--trace -Wl,-rpath,/usr/local/qt/lib -shared 
-Wl,-soname,libCommunicationModule-x11-Debug.so.6 -Wl,-rpath,/home/sncf/AGC_IHM/AGC/Tms/Gui/Components/CommunicationModule/x11/Debug 
-o libCommunicationModule-x11-Debug.so.6.0.1 x11/Debug/Obj/CommunicationModule-Build.o x11/Debug/Obj/CommunicationModuleFilesAutoGen.o x11/Debug/Obj/CommunicationModuleParamsAutoGen.o 
x11/Debug/Obj/CommunicationModule.o 
x11/Debug/Obj/CommunicationModuleAutoGen.o 
x11/Debug/Obj/CommDebugDlg.o 
x11/Debug/Obj/moc_CommunicationModule.o x11/Debug/Obj/moc_CommDebugDlg.o  
-L/usr/local/qt/lib 
-L/usr/X11R6/lib -lBuildInformations-x11-Debug 
-lBagsLib-x11-Debug -lConfigParamsLib-x11-Debug 
-lIniLib-x11-Debug -lModuleHandling-x11-Debug 
-lGenericRuntimeInfoLib-x11-Debug 
-lDebugLib-x11-Debug -lTCNLib-x11-Debug 
-lGUITools-x11-Debug -lQtEventsLib-x11-Debug 
-lPackUnpack-x11-Debug -L/home/sncf/AGC_IHM/AGC/Tms/Gui/ProjectLib/x11 
-L/home/sncf/AGC_IHM/AGC/Tms/Gui/Components/AGCTCNClientAPI/2004.09.21/posix_linux_i586/lib
-lqt-mt -lXext -lX11 -lm -lpthread -Wl,-whole-archive -ltgi_cppd -lstdc++ -lgcc 

Solution

  • You linked against a library which was compiled/linked by another compiler/linker version. What you need is to link against a library which was compiled and linked by the same compiler/linker as used by yourself, or you have to make sure, that the libraries are at least binary compatible.