首页 > 解决方案 > 如何编译旧的 ABI libstdc++?

问题描述

我的生产环境是 Centos 7,仅限于:

在那个环境下,无论我使用 gcc 4.8.5 还是 gcc 7.3.1 (devtoolset-7),它仍然使用旧的 ABI libstdc++。


我的开发环境是带有新libstdc++11gcc 8.4.1的Centos 8 Stream

当然,运行我在 Centos 8 Stream 上编译的应用程序,在 Centos 7 上,我得到了著名的:

问题:

Centos 8 Stream,我如何告诉 CMake 使用旧的 ABI以便它与 Centos 7 兼容?

柯南有一个compiler.libcxx=libstdc++选择。

我确实有set(CMAKE_CXX_STANDARD 11),两个 gcc 版本都支持 C++11。

尝试

CMake Warning:
  Manually-specified variables were not used by the project:

    _GLIBCXX_USE_CXX11_ABI

/usr/bin/ld: Dwarf Error: Invalid abstract instance DIE ref.
/tmp/ccXH3FbV.ltrans0.ltrans.o: In function `main':
<artificial>:(.text+0xbb5): undefined reference to `MyLib::getStateString[abi:cxx11]()'
<artificial>:(.text+0xbe0): undefined reference to `MyLib::getState2String[abi:cxx11]()'
<artificial>:(.text+0xeb8): undefined reference to `MyLib::MyLib(unsigned char, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'

标签: gcccmake

解决方案


推荐阅读