views:

316

answers:

5

I am working on redhat 5.2 on a project which spans several disparate organizations. Each organization delivers libraries which have been compiled with various versions of g++. Currently, these versions include 4.1.1, 4.1.2 and 4.3.1. I am trying to link all the libraries together into an executable using 4.1.2. What, if any, problems may I expect by doing this?? As an aside, is there a way to tell which ABI each compiler version builds to??

Thanks in advance!

+1  A: 

Maybe it is easier to static link the executable... makes a big binary, but runs on all platforms.

0x6adb015
+5  A: 

This ABI policy document details the compatibility between different ABI versions. According to that, the libstdc++.so library should be compatible, and the last time gcc broke binary compatibility was at 3.4. You should be fine.

ASk
A: 

There should be no problems linking libraries built from different versions of g++ unless they've been listed on the g++ website. What is important though is that these libraries be built on the same platform which in your case is redhat 5.2. A library built for a platform other than linux/redhat (say solaris) will not link with your exe.

fasih.ahmed
A: 

IIRC, there is a C++ compatibility library that is used to do just that. I think it's called libstdc++-compat.

Martin Cote
You can't link together objects which depend on different versions of stdlibc++.
ephemient
+3  A: 

GCC (GNU Compiler Collection) defines version numbers and compatibility.

The G++ libraries between 4.1.1 and 4.1.2 should be compatible; link with the newest.

The G++ libraries between 4.1.x and 4.2.x are not compatible; you need to recompile something.

The G++ libraries between 3.x.y and 4.p.q are not compatible; you need to recompile something.

In your scenario, the code built with 4.3.1 is not compatible with the rest.

Either you will have to rebuild the code currently compiled with 4.3.x so it uses 4.1.x, or you need to recompile the code currently compiled with 4.1.x so it uses 4.3.x instead.

Jonathan Leffler
That is the theory, but in the practice the last ABI change was 3.4
Edu Felipe
@Edu: but at any time in the future, there could be a change which invokes that rule, and people who have gotten sloppy about things may be in for a surprise (having to recompile).
Jonathan Leffler