链接器找不到boost :: thread引用

时间:2019-05-24 12:22:07

标签: c++ yocto boost-thread

背景

我正在将一个庞大的项目移植到一个新的工具链中(从 gcc 4.7.0 迁移到 gcc 8.2.0 ,并从 boost 1.55 提高1.68 )。整个SDK由Yocto生成。有几种库和应用程序,都是使用cmake构建的。

问题:

所有库都可以正常构建和链接,而某些使用boost::thread的应用程序无法正确链接。举一个例子:

cmake生成的命令:

  

cd /home/italia.priv.org/user/workspace-mk5/git/build/apps/ConfigMngr && /opt/cmake-3.13.0-Linux-x86_64/bin/cmake -E cmake_link_script CMakeFiles / ConfigMngr。 dir / link.txt --verbose = 1   /opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/bin/arm-poky-linux-gnueabi/arm-poky-linux-gnueabi-g++ --sysroot = / opt / poky / 2.6.2 / sysroots / armv7at2hf-neon-poky-linux-gnueabi --std = c ++ 11 -march = armv7-a -mthumb -mfpu = neon -mfloat-abi = hard -fpermissive -O3 -DNDEBUG -Wl,-O1- Wl,-hash-style = gnu -Wl,-根据需要CMakeFiles / ConfigMngr.dir / src / AppConfig.cpp.o CMakeFiles / ConfigMngr.dir / src / AppMain.cpp.o CMakeFiles / ConfigMngr.dir / src /AppStates.cpp.o CMakeFiles / ConfigMngr.dir / src / ConfigMngr.cpp.o CMakeFiles / ConfigMngr.dir / src / dbus_server / ConfigMngrServerApi.cpp.o -o ConfigMngr -Wl-rpath / home / italia.priv。 org / user / workspace-mk5 / git / targetfs / lib_priv / lib_arm:/opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libboost_chrono-mt.so / opt / poky /2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libboost_date_time-mt.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib /libboost_filesystem-mt.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/us r / lib / libboost_system-mt.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libboost_serialization-mt.so /opt/poky/2.6.2 /sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libboost_thread-mt.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib /libboost_timer-mt.so ../../../targetfs/lib_priv/lib_arm/libxxx_autocheck.so ../../../targetfs/lib_priv/lib_arm/libxxx_config.so ../../.。 /targetfs/lib_priv/lib_arm/libxxx_dbusapi.a ../../../targetfs/lib_priv/lib_arm/libxxx_hwifc.a ../../../targetfs/lib_priv/lib_arm/libxxx_log.so ../。 ./../targetfs/lib_priv/lib_arm/libxxx_utils.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libdbus-cxx.so /opt/poky/2.6 .2 / sysroots / armv7at2hf-neon-poky-linux-gnueabi / usr / lib / libsigc-2.0.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libodb .so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libodb-sqlite.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon- poky-linux-gnueabi / usr / lib / libodb-boost.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libsqlite3.so /opt/poky/2.6。 2 / sysroots / armv7at2hf-neon-poky-linux-gnueabi / usr / lib / libdbus-1.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libboost_date_time- mt.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libboost_atomic-mt.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky- linux-gnueabi / usr / lib / libboost_chrono-mt.so /opt/poky/2.6.2/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/lib/libboost_filesystem-mt.so /opt/poky/2.6。 2 / sysroots / armv7at2hf-neon-poky-linux-gnueabi / usr / lib / libboost_system-mt.so ../../../targetfs/lib_priv/lib_arm/libxxx_core.so /opt/poky/2.6.2/ sysroots / armv7at2hf-neon-poky-linux-gnueabi / usr / lib / libgtest.a -pthread

您可以在粗体中看到libboost_thread传递给链接器(它是指向实际lib的链接)。上面的命令输出:

  

/opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld: ../../../targetfs/lib_priv/lib_arm/libxxx_core.so:对“ boost :: this_thread :: interruption_point()”的未定义引用   /opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld:../ ../../targetfs/lib_priv/lib_arm/libxxx_core.so:对'boost :: thread :: native_handle()'的未定义引用   /opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld:../ .....   /opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld:../ ../../targetfs/lib_priv/lib_arm/libxxx_core.so:未定义对'typeinfo的boost :: detail :: thread_data_base引用   /opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld:../ ../../targetfs/lib_priv/lib_arm/libxxx_core.so:对“ boost :: detail :: get_current_thread_data()”的未定义引用   /opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld:../ ../../targetfs/lib_priv/lib_arm/libxxx_core.so:对“ boost :: this_thread :: interruption_requested()”的未定义引用   /opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld:../ ../../targetfs/lib_priv/lib_arm/libxxx_core.so:未定义对'boost :: detail :: thread_data_base ::〜thread_data_base()的引用   /opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld:../ ../../targetfs/lib_priv/lib_arm/libxxx_core.so:对“ boost :: thread :: detach()”的未定义引用   /opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld:../ ../../targetfs/lib_priv/lib_arm/libxxx_core.so:对“ boost :: chrono :: steady_clock :: now()”的未定义引用   /opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld:../ ../../targetfs/lib_priv/lib_arm/libxxx_core.so:对“ boost :: thread :: join_noexcept()”的未定义引用   /opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld:../ ../../targetfs/lib_priv/lib_arm/libxxx_core.so:对“ boost :: thread :: interrupt()”的未定义引用   /opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld:../ ../../targetfs/lib_priv/lib_arm/libxxx_core.so:对“ boost :: thread :: start_thread_noexcept()”的未定义引用   /opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld:../ ../../targetfs/lib_priv/lib_arm/libxxx_core.so:对“ vtable for boost :: detail :: thread_data_base”的未定义引用

查看libxxx_core导出的符号并grepping未定义引用之一:

nm -DC libxxx_core.so | grep thread::native_handle
U boost::thread::native_handle()     

U =>该符号未定义。

然后在libboost_thread中寻找相同的符号:

nm -DC libboost_thread.so.1.68.0 | grep native_handle
0000c3b1 T boost::thread::native_handle()

T =>该符号位于文本(代码)部分。

因此,链接程序应该能够解决此依赖性(和其他依赖性)。

我们尝试过的事情

  • 重新排序库({{1}之前和之后的libxx_core
  • 检查每个未解析的符号
  • 尝试了不同的环境

在未定义的引用中,链接器给出的最后一个错误是

  

/opt/poky/2.6.2/sysroots/x86_64-pokysdk-linux/usr/libexec/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/8.2.0/real-ld: ../../../targetfs/lib_priv/lib_arm/libxxx_core.so:未定义对“ vtable for boost :: detail :: thread_data_base”的引用

可能与未定义的引用有关。我也在努力。

问题

关于可能导致这些错误的原因的任何想法,或有关如何正确调试此行为的建议?

谢谢, 加布里埃

0 个答案:

没有答案