gcc 5.2.1 _GLIBCXX_USE_CXX11_ABI

gcc 5.2.1 _GLIBCXX_USE_CXX11_ABI

本文关键字:USE CXX11 ABI GLIBCXX gcc      更新时间:2023-10-16

EDIT:我使用的是gcc 5.2.1,所以很明显,现在默认情况下选择了库-一个新的libstdc++库ABI。当我试图编译我的代码:时,这可能是导致此错误消息的问题(与std::__cxx11有关)

/tmp/ccVIU5fG.o: In function `main':
2D_interpolations.cc:(.text+0x76): undefined reference to `mio::Config::Config(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
2D_interpolations.cc:(.text+0x151): undefined reference to `mio::IOUtils::convertString(mio::Date&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, double const&, std::ios_base& (*)(std::ios_base&))'

我尝试在.cc文件的开头添加以下行

#define _GLIBCXX_USE_CXX11_ABI 0

然后我就可以编译了。但我遇到了一个与未定义符号有关的错误。通过使用

c++filt <the undefined symbol>

事实证明,在添加#define _GLIBCXX_USE_CXX11_ABI 0之前,未定义的符号实际上与我得到错误的位置完全相同

mio::Config::Config(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)

通过检查是否存在其他未定义的符号,我认为其中也缺少一个(也在以前的错误中)

mio::IOUtils::convertString(mio::Date&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, double const&, std::ios_base& (*)(std::ios_base&))

我知道已经有一些类似的帖子了,但答案对我来说太"理论化"了,因为我是c++的新手,而且我对计算机一无所知。。。如果你有任何可以帮助的建议,欢迎你!

谢谢!

我终于解决了所有问题,所以我在这里发布了解决方案,以防感兴趣

为了检查我的代码使用了哪些库,我使用了命令

ldd -r -d <name of my code file>

通过路径正确检测到使用的第三方lib Im

/usr/local/lib/<name of the library file>

但这显然不是一条好路(不要问我为什么),即使被认可。一个好的选择是将库文件更改到另一个位置:

/usr/lib/<name of the library file>

它现在工作得很完美!