are gcc-3 binaries compatible with gcc-4

1.2k views Asked by At

I have a static library that has been compiled with gcc 3.4.3 .I would like to use this in code that will now be compiled with gcc-4. I've read vaguely that gcc-3 and gcc-4 binaries are not compatible and that the library will need to be recompiled , but just want confirmation on this. Isn't there anyway a gcc-3 library can be used with gcc-4 ?

1

There are 1 answers

4
Erik Olson On BEST ANSWER

Getting someone else in the organization, or at a vendor, to update their library to gcc 4 is not always an option, especially if they've abandoned it.

If C++: assuming that are able to link, at runtime you can blow up in C++ standard library template code that uses streams, as symbols generated by g++ 4 are resolved against definitions generated by g++ 3.

You might see this warning when linking:

/usr/bin/ld: warning: libstdc++.so.5, needed by (legacy static lib), may conflict with libstdc++.so.6

Here's an example you can get into: base class destructor ~basic_stringbuf() (actually a template) can be defined in your module compiled under g++ 3, which mistakenly gets called by the destructor ~basic_ostringstream() in libstdc++so.6, which is invoked by the g++ 4 compiled module. Ka-Boom.

I tried compat-libstdc++-33 but had no luck with that.

That said, I still link 32-bit gcc 3 era C libraries into my gcc 4.1.2 C++ programs.