using GCC 4.4 library with GCC 4.8 application

804 views Asked by At

I am writing an application and I would like to use GCC 4.8 on rhel7. My problem is that I need to use a 3rd party shared lib which was built using GCC 4.4 built on rhel6.

1

There are 1 answers

0
yugr On

Someone suggested I create an interface between my app and the library using extern "C" to avoid ABI issues of going between c++03 to c++11, and only pass simple C structs in the interface.

That's a meaningful suggestion as it's too hard to preserve ABI compatibility in C++ interfaces.

But they also suggested its possible I might have to copy and link libstdc++ and libgcc from the rhel6 machine since the 3rd party lib (and my interface) is built using those. This is where I am confused.

Both libgcc and libstdc++ preserve backwards compatibility (unless in GCC5 but that's not your case) so the 3rd party lib should work just fine with RHEL7 libs.

Given that the major version (libName.so.major.minor.x.z) of libstdc++ and libgcc is the same on rhel6 and 7, do I really need to copy them from rhel6 to 7?

No (see above).

Cant I build my interface on rhel6, and just copy it along with 3rd party lib to rhel7 (without copying old libstdc++/libgcc)?

Yes, this will work.

I mean, since stuff built using old libstdc++/libgcc should be forward compatiable, no?

Correct (they usually say that "new versions of standard libs are backwards compatible i.e. software compiled with older libs will continue to work").

Can I run into issues (ABIs)?

If you somehow manage to pass STL object created in one libstdc++ to another you'll have weird errors. But if both your and 3rd party library have pure C interfaces this should not be an issue (as there's no way for STL objects to escape their containing libraries).

If I do need to copy libstdc++ and libgcc from rhel6, and link new and old versions together -- how do i do that? will there suggestion of statically linking the new versions work?

This would be unnecessary burden.