views:

73

answers:

2

This is a specific gcc related question. I have a library compiled with g++ 4.1.2 that I want to give the user. The user can use our API in their code and link our library to create the final executable.

The question I have is related to g++ version compatibility. Some of our users are using g++ 4.4.3, others 4.3.3, and still others 4.2.1. Is the library compiled with 4.1.2 compatible with all these g++ versions? My guess is they should be because they are ABI compatible. But some of our customers don't agree. I really don't want to ship four different versions of the same library. If they are incompatible is there a concrete reason or is there a way to avoid the incompatibility?

+1  A: 

In short, yes. If your application does not use features of the new GCC, you can safely compile it with an older GCC. GCC is made to be backwards compatible, applications built with older GCC Libraries won't break on newer versions.

Lekensteyn
+3  A: 

Two libraries are compatible with each other as long as they use the same ABI (Application Binary Interface). The last time GCC officially changed the ABI, as far as I recall, was with v3.3 or v3.4.

However, this is only true for compliant code. Any source that relies on undocumented or unspecified behaviour might break without further notice.

So the answer is: Your compiler versions are all compatible; the question is whether the source code is.

DevSolar
User "Employed Russian" pointed out that "...there was an incompatibility in libstdc++.so.6.0.9 shipped with GCC 4.2.1." Thanks for the add-on.
DevSolar