Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Compile boost with GCC 5 using old ABI?

I have downloaded a library that was compiled with a gcc 4.8 before the ABI change in GCC.

On my laptop (latest kubuntu) I have GCC 5.2. And When I installed boost, it seems that it used the new ABI but then I get the following link errors

undefined symbol.....__cxx11....

How can I install boost using old ABI with GCC5 ?

like image 933
Issam T. Avatar asked Mar 30 '16 12:03

Issam T.


People also ask

Which C++ ABI does GCC use?

From GCC version 3 onwards the GNU C++ compiler uses an industry-standard C++ ABI, the Itanium C++ ABI. The GNU C++ compiler, g++, has a compiler command line option to switch between various different C++ ABIs. This explicit version switch is the flag -fabi-version.

What is Abi in C++ compiler?

These details are defined as the compiler Application Binary Interface, or ABI. From GCC version 3 onwards the GNU C++ compiler uses an industry-standard C++ ABI, the Itanium C++ ABI. The GNU C++ compiler, g++, has a compiler command line option to switch between various different C++ ABIs.

Can I use a clang build boost with GCC?

Please note, that a C++ library compiled with GCC is not compatible with Clang and vice-versa. So, you won’t be able to use a Clang build Boost with GCC … For the GCC version, you can compile and run the above code with: For the Clang version, you can compile and run the above code with:

Is my compiler using the new cxx11 Abi?

However, if you are using GCC >= 5 your compiler is likely to be using the new CXX11 ABI by default (libstdc++11). This can be checked with the following command:


1 Answers

To my knowledge, there are no prebuilt Boost packages for the old ABI in the official Kubuntu repositories, so you will have to build Boost yourself. The building process is documented here.

Make sure you're building the same Boost version that was used when your library was built. If there were any Boost configuration macros defined, you will also have to define them the similar way. Otherwise you may encounter ABI incompatibilities between the library and Boost you've built.

In order to switch libstdc++ to the old ABI you will also have to define _GLIBCXX_USE_CXX11_ABI to 0, as described here. For example:

b2 -j8 variant=release define=_GLIBCXX_USE_CXX11_ABI=0 stage

You will also need to define the macro when you build your own code that uses Boost and the library.

The define property, along with many others, is documented here.

like image 64
Andrey Semashev Avatar answered Oct 20 '22 06:10

Andrey Semashev