1. 编译安装
2. 导出LD_LIBRARY_PATH 是非常必要的, 不然很多时候link会出现找不到 GLIBCXX 3.4 这种错误。
3. gcc 5.1 以后 使用了双重标准的ABI, 也就是引入了新的ABI, 详见
In the GCC 5.1 release libstdc++ introduced a new library ABI that includes new implementations of std::string
and std::list
.
These changes were necessary to conform to the 2011 C++ standard which forbids Copy-On-Write strings and requires lists to keep track of their size.
重新实现了string 和 list, 主要是为了c11 标准的禁止写时复制和需要lists跟踪自身size大小,提供了 O(1) 的size函数。
正常情况下 ,可以通过在include标准库文件之前,设置宏
_GLIBCXX_USE_CXX11_ABI 为0来禁止新的ABI, 此ABI不受 -std=xxx 的影响。
但是我们在使用之前版本编译的第三方库的时候,可能会出现未定义的错误, 比如我在用gcc 5.2 开发工程的时候,
链接了一个gcc 4.4 编译的protobuf, 然后就出现了一堆未定义的错误。这时候就需要将protobuf 用新的gcc 5.2 再编译一遍,就可以了。
否则需要 将全部工程都使用旧的ABI。
Troubleshooting
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.
refer:
阅读(2081) | 评论(0) | 转发(0) |