Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

G++ new ABI problems

Tags:

c++

gcc

c++11

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?

like image 213
Maelkum Avatar asked Jan 24 '16 00:01

Maelkum


People also ask

Why is my Abi not working in GCC?

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.

What are the US guidelines on Abi measurement in asymptomatic patients?

However, in the US guidelines, measuring ABI in asymptomatic patients is a class IIa recommendation (reasonable). 6 The IIa recommendation is based on the fact that these patients warrant intensive atherosclerosis risk factor reduction regardless of the ABI.

Which Abi should I use for C++11?

Although the changes were made for C++11 conformance, the choice of ABI to use is independent of the -std option used to compile your code, i.e. for a given GCC build the default value of the _GLIBCXX_USE_CXX11_ABI macro is the same for all dialects.

What is the importance of ABI for risk assessment of peripheral artery disease?

Lowering cardiovascular risk factors is important for preventing PAD progression and has other benefits, including decreasing the risk of cardiac events and stroke. Measuring an ABI for risk assessment refers to its use in patients at elevated cardiovascular risk (e.g. smokers, or patients with coronary disease), but who do not have leg symptoms.


1 Answers

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.

like image 122
Sam Varshavchik Avatar answered Nov 03 '22 01:11

Sam Varshavchik