2012-08-07 26 views
1

我在编译odbc sdk中的一些示例时遇到了问题。经过一段时间与图书馆订单混合在一起后,我以某种方式设法将未定义的引用数量仅限于其中的一小部分。libpthread和libc中的未定义引用

不幸的是,我无法弄清楚如何摆脱其余的。这里是一个的失败的命令:

g++ -Wall -z defs -m64 -DSIMBA -D_REENTRANT -fPIC -O0 -g -shared Common/TabbedUnicodeFileReader_Linux_x8664_debug.cpp.o Core/QSConnection_Linux_x8664_debug.cpp.o Core/QSDriver_Linux_x8664_debug.cpp.o Core/QSEnvironment_Linux_x8664_debug.cpp.o Core/QSStatement_Linux_x8664_debug.cpp.o DataEngine/QSDataEngine_Linux_x8664_debug.cpp.o DataEngine/QSMetadataHelper_Linux_x8664_debug.cpp.o DataEngine/QSTable_Linux_x8664_debug.cpp.o DataEngine/QSTableUtilities_Linux_x8664_debug.cpp.o DataEngine/QSTypeInfoMetadataSource_Linux_x8664_debug.cpp.o Common/QSTableMetadataFile_Unix_Linux_x8664_debug.cpp.o Common/QSUtilities_Unix_Linux_x8664_debug.cpp.o Main_Unix_Linux_x8664_debug.cpp.o -Wl,--no-undefined -Wl,--no-allow-shlib-undefined -Wl,--whole-archive,/home/hector/Downloads/SimbaEngineSDK/9.0/DataAccessComponents//Lib/Linux_x8664/libSimbaDSI_debug.a,/home/hector/Downloads/SimbaEngineSDK/9.0/DataAccessComponents//Lib/Linux_x8664/libSimbaSupport_debug.a,/home/hector/Downloads/SimbaEngineSDK/9.0/DataAccessComponents//Lib/Linux_x8664/libAEProcessor_debug.a,/home/hector/Downloads/SimbaEngineSDK/9.0/DataAccessComponents//Lib/Linux_x8664/libCore_debug.a,/home/hector/Downloads/SimbaEngineSDK/9.0/DataAccessComponents//Lib/Linux_x8664/libDSIExt_debug.a,/home/hector/Downloads/SimbaEngineSDK/9.0/DataAccessComponents//Lib/Linux_x8664/libExecutor_debug.a,/home/hector/Downloads/SimbaEngineSDK/9.0/DataAccessComponents//Lib/Linux_x8664/libParser_debug.a,/home/hector/Downloads/SimbaEngineSDK/9.0/DataAccessComponents//Lib/Linux_x8664/libSimbaODBC_debug.a -Wl,--no-whole-archive -Wl,--soname=../Bin/Linux_x8664/libQuickstart_debug.so -L/home/hector/Downloads/SimbaEngineSDK/9.0/DataAccessComponents//ThirdParty/icu/Linux_x8664/lib -licuuc_simba64 -licudata_simba64 -licui18n_simba64 -lpthread -lm -lc -ldl -Wl,--version-script=exports_Linux.map -o ../Bin/Linux_x8664/libQuickstart_debug.so 

编辑:缺少符号

/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libdl.so: undefined reference to `[email protected]_PRIVATE' 
/lib/x86_64-linux-gnu/libpthread.so.0: undefined reference to `[email protected]_PRIVATE' 
/lib/x86_64-linux-gnu/libpthread.so.0: undefined reference to `[email protected]_2.2.5' 
/lib/x86_64-linux-gnu/libpthread.so.0: undefined reference to `[email protected]_PRIVATE' 
/lib/x86_64-linux-gnu/libpthread.so.0: undefined reference to `[email protected]_2.3' 
/lib/x86_64-linux-gnu/libpthread.so.0: undefined reference to `[email protected]_PRIVATE' 
/lib/x86_64-linux-gnu/libpthread.so.0: undefined reference to `[email protected]_PRIVATE' 
/lib/x86_64-linux-gnu/libc.so.6: undefined reference to `[email protected]_PRIVATE' 
/lib/x86_64-linux-gnu/libc.so.6: undefined reference to `[email protected]_PRIVATE' 
/lib/x86_64-linux-gnu/libpthread.so.0: undefined reference to `[email protected]_PRIVATE' 
/lib/x86_64-linux-gnu/libpthread.so.0: undefined reference to `[email protected]_PRIVATE' 
/lib/x86_64-linux-gnu/libpthread.so.0: undefined reference to `[email protected]_PRIVATE' 

修正:删除轮候册,

- 没有让 - SHLIB-未定义似乎这样的伎俩。构建的共享库看起来很完美。

+0

发布您正在收到的错误消息。 – stark 2012-08-07 10:53:02

+0

哪些符号丢失?我在帖子中看不到... – jcoder 2012-08-07 10:53:49

回答

3

你做了一个很常见的新手错误。您可以将库链接到命令行的中间或开头。链接器GCC使用反向顺序中的需求依赖关系。这意味着如果使用库L中的函数有源/目标文件S,则文件A必须在命令行上的库L之前。

简而言之,将库(-lm -lc -ldl)最后放在命令行上。

+0

我试过了,但我仍然得到相同的未定义参考文献 – 2012-08-07 11:11:21

+0

@HectorIzquierdo您在两个地方有一些库。如果链接器已经加载了一个库,它将不会再加载它,然后查找将失败。删除源文件/目标文件之前的所有库,并将它们保留在最后。 – 2012-08-07 11:18:39

+0

感谢提示Joachim。可悲的是我仍然得到相同的未定义的参考错误 – 2012-08-07 11:27:46

1

如果链接器无法解析所有引用的符号,那么这可能是提供的库的顺序错误的结果。如果你不确定什么是正确的顺序,然后把档案放入“--start-group archives --end-group”,根据ld手册将强制链接器重复搜索指定的档案,直到没有新的未定义的参考被创建。但要注意性能成本。