简体   繁体   English

G++ 新的 ABI 问题

[英]G++ new ABI problems

I got a problem with the new ABI introduced for C++11 in GCC.我在 GCC 中为 C++11 引入的新 ABI 有问题。 After upgrading to GCC 5.3 my project does no longer compile.升级到 GCC 5.3 后,我的项目不再编译。 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)?所以,看起来我搞砸了一些东西,GCC 无法决定我是想要旧的 ABI 还是新的( __cxx11::部分在某些错误消息中丢失,而在其他错误消息中存在)?

I tried several solutions to resolve the issue:我尝试了几种解决方案来解决这个问题:

  • passing -D_GLIBCXX_USE_CXX11_ABI=0 to GCC,-D_GLIBCXX_USE_CXX11_ABI=0传递给 GCC,
  • passing -D_GLIBCXX_USE_CXX11_ABI=1 to GCC,-D_GLIBCXX_USE_CXX11_ABI=1传递给 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,在传递-Wabi-tag标志时,在 GCC 抱怨的声明上设置abi_tag属性,

Unfortunately, neither of them worked (ie 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.我知道的一件事是,只有返回std::string或将其作为参数的函数才能链接。 Which is to be expected, given what I read about the problem on the Internet.考虑到我在 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.此错误表明您正在链接到一些未经 gcc 5.3 重新编译的代码或库,而是由较早版本的 gcc 使用较早版本的 ABI 编译的。

If you are linking with some external libraries, besides the standard C++ library, those external libraries need to be recompiled (and reinstalled).如果您正在链接一些外部库,除了标准的 C++ 库之外,还需要重新编译(并重新安装)这些外部库。

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.确保使用make clean或您正在使用的任何构建系统的等效项擦除所有现有的对象模块。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM