我使用 c++11,但也有一些库没有为它配置,需要一些类型转换。特别是我需要一种将 std::__cxx11::string
转换为常规 std::string
的方法,但谷歌搜索我找不到这样做的方法并将前面的 (string)
不起作用。
如果我不转换,我会收到这样的链接器错误:
undefined reference to `H5::CompType::insertMember(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, unsigned long, H5::DataType const&) const'
最佳答案
您可能使用的是 GCC 5 吗?
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.
来源:GCC 5 Release Notes/Dual ABI
定义以下宏之前包括任何标准库头应该可以解决您的问题:#define _GLIBCXX_USE_CXX11_ABI 0
关于c++ - 将 std::__cxx11::string 转换为 std::string,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53404397/