问题描述
在GCC中为C ++ 11引入的新ABI有问题。升级到GCC 5.3后,我的项目不再编译。我得到的错误消息很简单:
未定义引用`tokenize(std :: __ cxx11 :: basic_string'...字符
或
未定义的引用`extract(std :: string const&)'
它看起来像我搞砸了一些东西,GCC无法决定是否需要旧的ABI或新的( __ cxx11 ::
部分缺少一些错误消息,
- >将
-D_GLIBCXX_USE_CXX11_ABI = 0
传递给GCC, - 传递
-D_GLIBCXX_USE_CXX11_ABI = 1
to gcc, - 直接在源代码中设置宏,
- 设置
abi_tag
GCC在传递-Wabi-tag
标志时声明的属性,
不幸的是,他们都没有工作(即允许代码编译)。我知道的一件事是,只有返回 std :: string
或将其作为参数的函数无法链接。考虑到我在互联网上阅读的这个问题,这是可以预期的。我无法在一个简单的示例程序中重现这个问题,在这里展示。
我的问题有没有明显的解决方案,我缺少?
此错误表示您链接到一些没有被gcc 5.3重新编译的代码或库,
如果您要连接一些外部库,除了标准的C ++库外,这些外部库需要重新编译
如果您没有与任何外部库链接,并且您只是将自己的代码链接在一起,那么您的一些源代码模块不能重新编译然而。重新编译一切。确保使用 make clean
或所使用的任何构建系统的等效项来擦除所有现有的对象模块。
I got a problem with the new ABI introduced for C++11 in GCC. After upgrading to GCC 5.3 my project does no longer compile. The error messages I get are simple:
undefined reference to `tokenize(std::__cxx11::basic_string' ...more characters
or
undefined reference to `extract(std::string const&)'
So, it looks like I messed something up and GCC is unable to decide whether I want the old ABI or the new one (the __cxx11::
part is missing from some error messages, and present in others)?
I tried several solutions to resolve the issue:
- passing
-D_GLIBCXX_USE_CXX11_ABI=0
to GCC, - passing
-D_GLIBCXX_USE_CXX11_ABI=1
to GCC, - setting the macro directly in source code,
- setting the
abi_tag
attribute on the declarations GCC complained about when passed the-Wabi-tag
flag,
Unfortunately, neither of them worked (i.e. allowed the code to compile). The one thing I know is that only functions returning std::string
or taking it as a parameter fail to link. Which is to be expected, given what I read about the problem on the Internet. I was unable to reproduce the issue in a simple, example program to present it here.
Is there any obvious solution to my problem, that I am missing?
This error indicates that you're linking to some code or library that has not been recompiled by gcc 5.3, and was compiled by an earlier version of gcc, using the earlier version of the ABI.
If you are linking with some external libraries, besides the standard C++ library, those external libraries need to be recompiled (and reinstalled).
If you are not linking with any external libraries, and you are only linking together your own code, some of your source modules must not've been recompiled yet. Recompile everything. Make sure to wipe all existing object modules, with make clean
, or the equivalent for whatever build system you're using.
这篇关于G ++新的ABI问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!