gcc - 如何编译旧的 ABI libstdc++?
问题描述
我的生产环境是 Centos 7,仅限于:
- GLIBCXX_3.4.19
- CXXABI_1.3.7
在那个环境下,无论我使用 gcc 4.8.5 还是 gcc 7.3.1 (devtoolset-7),它仍然使用旧的 ABI libstdc++。
我的开发环境是带有新libstdc++11和gcc 8.4.1的Centos 8 Stream:
- GLIBCXX_3.4.25
- CXXABI_1.3.11
当然,运行我在 Centos 8 Stream 上编译的应用程序,在 Centos 7 上,我得到了著名的:
- 未找到版本 GLIBCXX_3.4.20'
- 未找到版本 CXXABI_1.3.9'
问题:
从Centos 8 Stream,我如何告诉 CMake 使用旧的 ABI以便它与 Centos 7 兼容?
柯南有一个compiler.libcxx=libstdc++
选择。
我确实有set(CMAKE_CXX_STANDARD 11)
,两个 gcc 版本都支持 C++11。
尝试
cmake -D_GLIBCXX_USE_CXX11_ABI=0 ..
CMake Warning:
Manually-specified variables were not used by the project:
_GLIBCXX_USE_CXX11_ABI
-DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0
/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&)'
解决方案
推荐阅读
- .htaccess - 子域重定向到外部 url 路径并保留子域的名称
- java - 针对特定的 Micronaut WebSocket 连接
- android - Display emojis with skin color variation in a textfield via unicode
- google-apps-script - ConvertApi 和 Google Script:我有时会收到“合并 pdf 时出现错误 500”,但并非总是如此
- java - 使用 db2 格式化字符串中的数字,错误“为 varchar 指定的参数数量无效”
- vba - VBA CreateObject("Shell.Application").Open strURL does not work
- dynamics-crm - 产品实体中相关选项卡上的重复项目捆绑实体引用
- angular - 在地图Angular agm中添加mapTypeOptions
- heroku - Buy hours from heroku
- mysql - replace() 不是函数 nodejs