编辑:我正在使用 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
然后我就可以编译了。但是我收到与 undefined symbol 相关的错误。通过使用
c++filt <the undefined symbol>
事实证明,在添加#define _GLIBCXX_USE_CXX11_ABI 0之前, undefined symbol 实际上是在与我收到错误的位置完全相同的位置未定义
mio::Config::Config(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
通过检查是否存在其他 undefined symbol ,我认为那里也缺少一个(也是在之前的错误中)
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>
通过路径正确检测到我使用的第 3 方库
/usr/local/lib/<name of the library file>
但这显然不是一个好的路径(不要问我为什么),即使被认可。一个不错的选择是将库文件更改到另一个位置:
/usr/lib/<name of the library file>
现在可以完美运行了!
关于c++ - 海湾合作委员会 5.2.1 _GLIBCXX_USE_CXX11_ABI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36190135/