Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a C++14/17 project use binary libraries compiled using C++11 standard or does the source code need to be recompiled?

Can a binary which was compiled using C++11 be used in a c++14/17 project? What about a c++14 binary library in a c++17 project?

Or would the source code need to be updated and recompiled using the same standard as the project?

Are there any other ways to include older standard C++ libraries in new standard projects?

like image 736
Greg Avatar asked Oct 25 '17 04:10

Greg


1 Answers

The C++ standard has nothing todo with the file format of the binary. That only depends on the compilers/linkers and the OS. So if the compiler vendor changes the ABI ( Application binary interface ), you can not simply link the parts together.

As you can read here, only relevant for gcc:

https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html

gcc introduces with gcc5.1 a new ABI. A history of versions of libraries from gcc and maybe comments to ABI changes can be found here:

https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html

So changing from one C++ version to another did not change the ABI but changing the compiler can.

like image 143
Klaus Avatar answered Oct 29 '22 11:10

Klaus