简体   繁体   English

升级版本冲突

[英]Conflicting boost versions

I have compiled boost::system and boost::serialization from with the older GCC ABI ( https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html ) due to some older third-party code I'm using. 由于某些旧的第三方代码,我使用较旧的GCC ABI( https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html )编译了boost::systemboost::serialization使用。

I had them built to /usr/local/lib which is already set as a valid path to the linker (I use other libraries there as well), and renamed them to: 我将它们构建到/usr/local/lib ,该文件已经被设置为链接器的有效路径(我也在那里使用其他库),并将它们重命名为:

$ ls /usr/local/lib/libboost_*

/usr/local/lib/libboost_serialization_old_abi.so
/usr/local/lib/libboost_serialization_old_abi.so.1.60.0
/usr/local/lib/libboost_system_old_abi.so
/usr/local/lib/libboost_system_old_abi.so.1.60.0
/usr/local/lib/libboost_wserialization_old_abi.so
/usr/local/lib/libboost_wserialization_old_abi.so.1.60.0

Default, mainstream boost libraries are under /usr/lib as usual. 缺省情况下,主流的boost库像往常一样在/usr/lib下。 What happens is that when I link any piece of code to these specific libraries with the custom flags -lboost_system_old_abi and -lboost_serialization_old_abi , the resulting binary will be linked to the default boost libraries : 发生的是,当我使用自定义标志-lboost_system_old_abi-lboost_serialization_old_abi将任何代码段链接到这些特定库时,生成的二进制文件将链接到默认的boost库

$ ldd darwin_socket

linux-vdso.so.1 (0x00007ffd137ea000)
/usr/local/webots/resources/projects/robots/darwin-op/libraries/darwin/libdarwin.so (0x00007fcb9edaa000)
libipsocket.so.1 => /usr/local/lib/libipsocket.so.1 (0x00007fcb9eb7b000)
libboost_system.so.1.60.0 => /usr/lib/libboost_system.so.1.60.0 (0x00007fcb9e977000)
libboost_serialization.so.1.60.0 => /usr/lib/libboost_serialization.so.1.60.0 (0x00007fcb9e739000)
libController.so => not found
libCppController.so => not found
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00007fcb9e3b7000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007fcb9e0b2000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x00007fcb9de9c000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007fcb9dafb000)
/lib64/ld-linux-x86-64.so.2 (0x00007fcb9efc1000)
librt.so.1 => /usr/lib/librt.so.1 (0x00007fcb9d8f3000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007fcb9d6d6000)

which is quite strange, because, if use original -lboost_system and -lboost_serialization flags, gcc can't even link to the default boost due to new/old ABI incompatibilities. 这很奇怪,因为如果使用原始的-lboost_system-lboost_serialization标志,由于新旧的ABI不兼容,gcc甚至无法链接到默认的boost。

So what exactly is happening here? 那么,这里到底发生了什么?

The problem is that just renaming your custom built libraries is not enough. 问题在于仅重命名自定义构建的库是不够的。 The library name is embedded into the library as soname (you can see it with the readelf -d command) and is used when your application is liked with the library. 库名称以soname的形式嵌入到库中(您可以使用readelf -d命令看到它),并且在您的应用程序被库喜欢时使用。 Basically, the sonames from the custom libraries are put as the dependencies into your application binary, and since they are the same as the official Boost library names, the wrong binaries are loaded in run time. 基本上,来自自定义库的soname会作为依赖项放入应用程序二进制文件中,并且由于它们与正式的Boost库名称相同,因此在运行时会加载错误的二进制文件。

You have to make sure the custom built Boost libraries are properly named in the build process. 您必须确保在构建过程中正确命名了自定义构建的Boost库。 You can try doing this by adding --buildid=old_abi option to your b2 command line. 您可以通过在b2命令行中添加--buildid=old_abi选项来尝试执行此操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM