0

I have a bunch of libraries built in RHEL 7 using gcc 4.7. Is the following possible

1) Can the binary be executed in RHEL 6 host without re-compiling ? 

2) The shared objects produced in RHEL 7 hosts with gcc 4.7 be used 
on a RHEL 6 with gcc 4.4 compiler ?

What are the caveats here ?

KodeWarrior
  • 3,538
  • 3
  • 26
  • 40

2 Answers2

1

If you won't link your binary statically, your problem would be shared libraries:

gcc usually links C programs with:

  • glibc -- implementation for C runtime library. RHEL 6 and 7 have different versions of that library. glibc uses symbol tagging, i.e.:

    myaut@panther:/tmp> readelf -s /lib64/libc.so.6 | grep ' open@'
    1679: 00000000000d8a70    90 FUNC    WEAK   DEFAULT   12 open@@GLIBC_2.2.5
    

    So if your program with link with function which has newer tag that is present in RHEL6, you won't be able to run your program.

  • libgcc_s is a GCC runtime that mostly contains functions that are not available on hardware platform (i.e. 32-bit binaries doesn't support 64-bit long long arithmetic, so they require library to do that), put it seem to be optional.

Finally, GCC 4.4 and 4.7 have compatible ABIs, so you shouldn't run into trouble due to different compilers.

myaut
  • 11,174
  • 2
  • 30
  • 62
0

If you use the GCC compiler included with the Red Hat Developer Toolset, RH guarantees that an app compiled on a major RHEL version will also run on the +1 version, e.g compile on RHEL 6 and run on either RHEL 6 or 7.

There's v4, but also GCC 5 and working on 6.

See http://developers.redhat.com/products/developertoolset/overview/

Mike Guerette
  • 533
  • 3
  • 6
  • How does this forward compatibility works? Does it mean that libraries are statically linked? – Oz. Mar 03 '17 at 10:34