Boost链接错误:缺少"B5cxx11"符号 [英] Boost linking error: 'B5cxx11' symbols missing
问题描述
这是问题所在:我正在使用的代码使用了一个与boost链接的大库.当我使用静态链接进行编译时,一切正常.但是,当我尝试动态链接时,会收到一堆未定义的参考错误.首先想到的显然是我没有链接boost program_options"库,但是我看了一下,它在链接命令中(它在需要它的库之后).但是,在不同的错误中,这一点很突出:
Here's the issue: the code I'm using uses a big library which links against boost. When I compile with static linking, everything works fine. However, when I try dynamic linking I get a bunch of undefined reference errors. The first thought was obviously "I am not linking the boost program_options" library, but I looked, and it is there in the linking command (and it comes after the library that needs it). Among the different errors, though, this stood out:
undefined reference to `_ZN5boost15program_options3argB5cxx11E
根据我的日常经验,链接错误通常是未定义对某项功能(...)的引用"的形式.因此,我进入了boost库的安装文件夹,并使用readelf
来查看库libboost_program.so
中的符号.实际上,该符号不会出现.相反,我找到的最接近的是_ZN5boost15program_options3argE
.
In my daily experience, linking errors are usually of the form "undefined reference to somefunction(...)". So I went to the installation folder of my boost library and used readelf
to see what symbols I have in the library libboost_program.so
. And in fact, that symbol does not appear. Instead, the closest I found is _ZN5boost15program_options3argE
.
对Google进行了一点操作后,我发现B5cxx11
的多余部分是自C ++ 11以来对名称处理的新添加.似乎boost(至少是1.59.0版)不支持此新名称处理.
Google-ing a little bit, I found out that the extra part B5cxx11
is a new addition to the name mangling since C++11. It appears that boost (at least version 1.59.0) does not yet support this new name mangling.
所以我的问题是:这是一个已知问题吗?有什么解决方法?为什么静态链接不会显示此问题?
So my question is: Is this a known issue? What workaround are there? And why does this issue not show up with static linking?
如果将来有人偶然发现此问题,我就尝试使用boost 1.60.0,并且符号包含字符串B5cxx11
.我相信(希望:)这将解决问题.不过,作为双重检查,我将再次重新编译boost 1.59.0,以查看这是否是由于我的环境发生了变化(尽管我对此表示怀疑).
In case someone stumbles on this question in the future, I just tried boost 1.60.0, and the symbols contain the string B5cxx11
. I believe (read: hope) this will solve the issue. As a double check, though, I am going to recompile again boost 1.59.0 to see if this is due to something I changed in my environment (although I doubt it).
推荐答案
我最近有一个类似的问题.我使用以下命令重新编译Boost库
I have a similar problem recently. I recompile my boost library using the following commands
./b2 --build-dir=build/x86 address-model=32 threading=multi --toolset=gcc --layout=versioned --stagedir=./stage/x86 -j 8
./b2 --build-dir=build/x64 address-model=64 threading=multi --toolset=gcc --layout=versioned --stagedir=./stage/x64 -j 8
然后使用编译我的程序
g++ main.cpp -L/home/research/boost_library/boost_1_68_0/stage/x64/lib/ -lboost_program_options-gcc82-mt-x64-1_68
这解决了我的问题.我在Redhat Linux上使用gcc 8.2
This solves my problem. I am using gcc 8.2 on redhat linux
这篇关于Boost链接错误:缺少"B5cxx11"符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!