简体   繁体   English

如何链接到与Linux中不同版本的Boost链接的共享库

[英]How to link against a shared library which linked with different version of boost in linux

I'm building a executable in a big project, one of its dependency, a .so file, is linked against boost 1.6.2, and the executable itself must be static linked to a different version of boost, I don't know the version of that, maybe 1.6.0, when I link to the .so directly, it's able to compile and link, but when I run that binary, the behaviour of that binary becomes strange when calling to the functions of classes of the external .so file, such as it can run into infinite lock, and core dump inside boost. 我在一个大项目中构建可执行文件,它的依赖项之一.so文件与boost 1.6.2链接在一起,并且可执行文件本身必须是静态链接到boost的不同版本的,我不知道的版本,也许是1.6.0,当我直接链接到.so时,它能够编译和链接,但是当我运行该二进制文件时,当调用external的类的函数时,该二进制文件的行为变得很奇怪。因此文件(例如它)可能会遇到无限锁定,并且boost中会发生核心转储。 But if I don't link a different version of boost, it works. 但是,如果我不链接其他版本的boost,它将起作用。 I guess the version of boost caused this problem. 我猜是boost版本引起了这个问题。 Is that true? 真的吗? How can I fix this? 我怎样才能解决这个问题?

The safest thing to do is to rename the namespace of your statically linked version of boost to ensure there are no symbol clashes. 最安全的方法是重命名boost的静态链接版本的名称空间,以确保没有符号冲突。 Unfortunately I don't think boost has any macros for changing its namespace so you'll have to do a manual find and replace in the source code. 不幸的是,我认为boost没有用于更改其名称空间的任何宏,因此您必须手动查找并替换源代码。

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

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