仅在Ubuntu 32 / 64bits上与`boost :: log2_mt`链接错误

时间:2013-09-11 14:59:32

标签: ubuntu gcc boost linker

我有一个庞大的项目,我使用boost。我的源代码树来自一个特定的文件夹,其中包含gcc 32位的头和lib,以及单独的子文件夹中的64位。

on Centos:Linux .... SMP Tue Jun 12 09:58:12 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux
没问题,每个链接都没问题。

但是Ubuntu上的同一个源代码树:Linux ... 3.2.0-48-generic #74-Ubuntu SMP Thu Jun 6 19:43:26 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux无法导致链接器错误。

libtest.so: undefined reference to `boost::log2_mt_posix::aux::sem_based_event::~sem_based_event()'
libtest.so: undefined reference to `boost::log2_mt_posix::aux::sem_based_event::sem_based_event()'
libtest.so: undefined reference to `boost::log2_mt_posix::aux::sem_based_event::set_signalled()'
libtest.so: undefined reference to `boost::log2_mt_posix::aux::sem_based_event::wait()'

下面是整个链接器命令行...欢迎任何帮助!

/usr/bin/ccache  g++      -m32 -lrt -L/home/abuisson/dev/fwk/build/lin32_release -L/home/abuisson/dev/fwk/Source/../Libs/boost/Lin32 -L/home/abuisson/dev/fwk/Source/../Libs/ace/Lin32 -L/home/abuisson/dev/fwk/Source/../Libs/SafeNetRMS/Lin32 -L/home/abuisson/dev/fwk/Source/../Libs/OpenSSL/bin/out32StaticMTReleaseLinux -L/home/abuisson/dev/fwk/Source/../Libs/TinyXML/Lin32/ReleaseStaticMT -L/home/abuisson/dev/fwk/Source/../Libs/zlib/Lin32 -L/home/abuisson/dev/fwk/Source/../Libs/Curl/Lin32 -L/home/abuisson/dev/fwk/Source/../Libs/microhttpd/Lin32 -L/home/abuisson/dev/fwk/Source/../Libs/Intel/Linux32 -L/home/abuisson/dev/fwk/Source/../Libs/IPP/Lin32 -L/home/abuisson/dev/fwk/Source/../Libs/xerces/lin32 CMakeFiles/Frameworktst.dir/Framework/FrameworkTst/FrameworkTimerTst.cpp.o CMakeFiles/Frameworktst.dir/Framework/FrameworkTst/FrameworkTst.cpp.o CMakeFiles/Frameworktst.dir/Framework/FrameworkTst/WriterTst.cpp.o CMakeFiles/Frameworktst.dir/Framework/FrameworkTst/FrameworkLogTst.cpp.o  -o Frameworktst  libFramework.so libVersionInfoLib.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_thread-gcc41-mt-1_49.a -lpthread /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_system-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_date_time-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_regex-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_signals-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_filesystem-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_program_options-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_log-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_log_setup-gcc41-mt-1_49.a -lpthread -ldl -lrt libTestMediaPlugin.so libFramework.so libVersionInfoLib.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_thread-gcc41-mt-1_49.a -lpthread /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_system-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_date_time-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_regex-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_signals-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_filesystem-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_program_options-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_log-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_log_setup-gcc41-mt-1_49.a -lpthread -ldl -lrt libTestAlgorithmPlugin.so libFramework.so libVersionInfoLib.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_thread-gcc41-mt-1_49.a -lpthread /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_system-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_date_time-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_regex-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_signals-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_filesystem-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_program_options-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_log-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_log_setup-gcc41-mt-1_49.a -lpthread -ldl -lrt libTestChannel.so libFramework.so libVersionInfoLib.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_thread-gcc41-mt-1_49.a -lpthread /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_system-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_date_time-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_regex-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_signals-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_filesystem-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_program_options-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_log-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_log_setup-gcc41-mt-1_49.a -lpthread -ldl -lrt libYaffut.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_thread-gcc41-mt-1_49.a -lpthread /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_system-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_date_time-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_regex-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_signals-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_filesystem-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_program_options-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_log-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_log_setup-gcc41-mt-1_49.a -lpthread libWMCommon.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_thread-gcc41-mt-1_49.a -lpthread /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_system-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_date_time-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_regex-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_signals-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_filesystem-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_program_options-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_log-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_log_setup-gcc41-mt-1_49.a -lpthread /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_thread-gcc41-mt-1_49.a -lpthread /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_system-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_date_time-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_regex-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_signals-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_filesystem-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_program_options-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_log-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_log_setup-gcc41-mt-1_49.a -lpthread /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_system-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_date_time-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_regex-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_signals-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_filesystem-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_program_options-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_log-gcc41-mt-1_49.a /home/abuisson/dev/fwk/Libs/boost/Lin32/libboost_log_setup-gcc41-mt-1_49.a -ldl -lrt -Wl,-rpath,/home/abuisson/dev/fwk/build/lin32_release
libFramework.so: undefined reference to `boost::log2_mt_posix::aux::sem_based_event::~sem_based_event()'
libFramework.so: undefined reference to `boost::log2_mt_posix::aux::sem_based_event::sem_based_event()'
libFramework.so: undefined reference to `boost::log2_mt_posix::aux::sem_based_event::set_signalled()'
libFramework.so: undefined reference to `boost::log2_mt_posix::aux::sem_based_event::wait()'

1 个答案:

答案 0 :(得分:0)

我们也有同样的问题,发现符号" sem_based_event"确实不存在于图书馆。然后问题是为什么,这个类的标题" sem_based_event"被包括在内。

问题的原因是我们尝试在gcc 4.4或更高版本的平台上使用使用gcc 4.1构建的boost库。

根据标志" __ GCC_HAVE_SYNC_COMPARE_AND_SWAP_4"启用/包含类sem_based_event。这是在gcc 4.3中介绍的。因此,当我们使用4.1版构建boost库时,不会包含/启用此类。但是,此标志既适用于定义,也适用于类" sem_based_event"的声明。在具有gcc 4.1(CentOs5.7)的平台上,声明也被禁用,我们不会看到任何链接器错误。但是,在具有gcc 4.4或更高版本(例如Ubuntu 10.10)的平台上,类的声明" sem_based_event"将在编译期间启用,如果我们仍尝试将其与使用4.1构建的boost日志库链接,它将无法找到符号,从而导致上述错误。

如何修复它:

使用正确编译的boost库版本,即使用与您要使用它相同的gcc版本编译boost库。