are gcc-3 binaries compatible with gcc-4
Asked Answered
R

1

9

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 ?

Ringtail answered 6/5, 2011 at 15:24 Comment(4)
gcc.gnu.org/onlinedocs/libstdc++/manual/abi.htmlClansman
You've tagged this both C++ and C. Does the library contain C++ code?Trig
Yes, although in separate libraries. Eg library1.a is c code . library2.a is cpp code.Ringtail
Why don't you just recompile and stop worrying about this?Narghile
B
3

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.

Bazooka answered 9/5, 2011 at 19:58 Comment(4)
It's actually a problem with name-mangling changes. C doesn't have these issues, so you can link against old C libraries.Durand
Usually. Sometimes the C libraries change to the point where link works but code doesn't. Almost always this is due to macro expansion of getc and friends.Soiree
However if the library is linked full static this will not be a problem.Soiree
Very Useful comments , but the answer to the question varies i guess , depending on the scenario one would or would NOT be able to link to older libraries.Ringtail

© 2022 - 2024 — McMap. All rights reserved.