c++ - 链接到动态库的静态库中的 undefined symbol

标签 c++ shared-libraries static-libraries undefined-symbol

这是我的问题:

在运行时我加载共享库的程序加载失败,它说:

libCommunicationModule.so: undefined symbol __builtin_delete

上下文:

  • 编译器:gcc 3.4
  • Linux Debian 4.0(老东西....)

我有一个静态库:libtgi_cppd.a,我没有这个库的源码。 这个库链接到共享库 libCommunicationModule.so 带有这些选项 -Wl,-whole-archive -ltgi_cppd

我在 __builtin_delete 上启用了 -y 选项来检查:

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

我尝试在-whole-archive前后添加链接命令-lstdc++ -lgcc,没有变化。

$ nm libCommunicationModule.so | grep __builtin

结果总是这样:

     U __builtin_delete
     U __builtin_new
     U __builtin_vec_new

我该怎么做才能解决这个问题?

谢谢

需要的完整命令:

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 

最佳答案

您链接到一个由另一个编译器/链接器版本编译/链接的库。您需要链接到一个由您自己使用的相同编译器/链接器编译和链接的库,或者您必须确保这些库至少是二进制兼容的。

关于c++ - 链接到动态库的静态库中的 undefined symbol ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27292627/

相关文章:

objective-c - 即使在删除 x86_64 要求后仍缺少所需的体系结构 x86_64

c - C 静态库上的错误处理实现

c++ - 在 AIX 上使用 pthread 进行静态链接

c++ - 从字符串中删除重复的字符

c++ - 这是一个有效的 C 语句吗?

c++ - 制作文件g++共享库

c++ - char数组字符串混淆

c++ - C++ 返回时触发事件

python - 从 Python 中的相对路径导入