您的位置:首页 > 编程语言 > C语言/C++

使用gcc 5 编译c++11编写的程序 出现的符号找不到的链接问题。

2017-09-14 00:12 477 查看
记录今天遇到的问题:

1. 使用c++11 写了一段c++程序,使用gcc 5.2编译。程序引用了非c++11编写的静态库

2. 链接时总是报某个函数找不到 但是使用nm命令查看,符号确实存在

经过google发现,原来gcc 5引入了新的ABI
https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
If you get linker errors about undefined references to symbols that involve types in the
std::__cxx11
namespace or the tag
[abi:cxx11]
then
it probably indicates that you are trying to link together object files that were compiled with different values for the _GLIBCXX_USE_CXX11_ABI macro. This commonly happens when linking
to a third-party library that was compiled with an older version of GCC. If the third-party library cannot be rebuilt with the new ABI then you will need to recompile your code with the old ABI.

对于我的问题,需要在参数上增加 -D_GLIBCXX_USE_CXX11_ABI=0 就解决了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐