Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is a GCC 4.7 compiled lib compatible with a GCC 4.6.3 program?

Tags:

c++

linux

gcc

c++11

I have a huge C++11 project with plugins like feature. My project has a few libs(compiled with gcc 4.6.3), a frontend (compiled with gcc 4.6.3) and some plugins (compiled with gcc 4.7). The plugins are loaded throught dlopen and reference stuff from the libs.

My project uses templates, typeinfo, shared_ptr, stl containers among other stuff.

When I compile everything with the same version of gcc everything runs okay. When I compile the way I described (libs and frontend in 4.6.3 and plugin on 4.7) I start facing problems.

I am not sure what is happening and I hope you can give me some clues and help me to work around this problem.

like image 978
André Puel Avatar asked Feb 21 '23 07:02

André Puel


2 Answers

G++ 4.6 is compatible with 4.7, despite what people are claiming here, as long as at runtime you use the libstdc++.so from the newest version used to build any object.

But for C++11 there are fewer guarantees as the support is still evolving (and until recently so was C++11!) so we've been unable to avoid making some incompatible changes in order to improve C++11 support.

For a more complete answer post details of your problems to the gcc-help mailing list and I'll look into it

like image 194
Jonathan Wakely Avatar answered Feb 22 '23 20:02

Jonathan Wakely


From http://gcc.gnu.org/gcc-4.7/changes.html:

GCC versions 4.7.0 and 4.7.1 had changes to the C++ standard library which affected the ABI in C++11 mode: a data member was added to std::list changing its size and altering the definitions of some member functions, and std::pair's move constructor was non-trivial which altered the calling convention for functions with std::pair arguments or return types. The ABI incompatibilities have been fixed for GCC version 4.7.2 but as a result C++11 code compiled with GCC 4.7.0 or 4.7.1 may be incompatible with C++11 code compiled with different GCC versions and with C++98/C++03 code compiled with any version.

I had problems with std::list<>

like image 43
ipapadop Avatar answered Feb 22 '23 21:02

ipapadop