使用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
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 就解决了。
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::__cxx11namespace 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 就解决了。
相关文章推荐
- 【Linux】使用vim编写一个程序,gcc查看预处理、编译、汇编、链接过程
- 1.2.在linux环境实践,使用vim编写一个程序,然后使用gcc查看【预处理】、【编译】、【汇编】、【链接】各阶段文件的内容。并熟悉相关指令。
- Linux操作系统的简单指令及如何使用vim编写一个程序,然后使用gcc查看【预处理】、【编译】、【汇编】、【链接】各阶段文件的内容。
- 共享库加载失败问题排查。gcc编译器生成共享库时不检查符号的依赖项。gcc编译器生成可执行程序时,会多链接一些无用的额库。
- VS2008编译DirectX SDK 2004 summer版的Sound例子程序出现的libcp.lib找不到的问题的解决办法
- 命令行使用javac及java编译、运行java程序出现的问题(Windows XP)
- 【转】关于使用Android6.0编译程序时,出现getSlotFromBufferLocked: unknown buffer: 0xac0f8650问题的解释
- 使用jikes编译java程序时出现的问题
- ubuntu下 GCC编译程序出现 undefined reference to `std::ios_base::Init::Init()'问题——gcc编译C++代码
- ubuntu下 GCC编译程序出现 undefined reference to `std::ios_base::Init::Init()'问题
- ubuntu下 GCC编译程序出现 undefined reference to `std::ios_base::Init::Init()'问题
- VS保存和编译问题] 总是出现另一个程序正在使用此文件,进程无法访问
- 解决Maven编译(maven install)时,出现的“找不到符号”的问题
- Linux下使用gcc编译程序找不到库的分析和解决方法
- 关于ios 程序加载百度地图lib,出现链接错误:找不到符号 (null): _OBJC_CLASS_$_BMKMapManager的解决办法
- 关于vs2010 C++编译链接总是出现“LNK:2019 无法解析的外部符号”的问题
- 关于使用Android6.0编译程序时,出现getSlotFromBufferLocked: unknown buffer: 0xac0f8650问题的解释
- ubuntu下 GCC编译程序出现 undefined reference to `std::ios_base::Init::Init()'问题
- 在WIN10系统下运行VS2013编译成功后出现:无法启动程序“.exe” 系统找不到指定文件的问题的解决方法
- 使用g++编译C/C++程序,链接时出现undefined reference to错误