Recent Changes - Search:

edit SideBar

My attempt of making GCC compiled binaries version neutral


As the original IBM GCC RPM package which I used as the starting point used the --enable-version-specific-runtime-libs configure switch the consequence is that when you compile/link a program with gcc/g++ that this version-specific runtime search path for shared libraries is compiled into the binary unless you use some precaution with the "-blibpath" linker flag. In order to stay compatible I had to keep that switch, i.e., stick to the same behavior as before.

The four runtime libraries are:

  • libgcc (libgcc_s.a, GCC C runtime library)
  • libstdc++ (libstdc++.a, GCC C++ runtime library)
  • libgomp (libgomp.a, GCC OpenMP runtime library)
  • libgfortran (libgfortran.a, GCC Fortran runtime library)

The GCC version-specific runtime libraries are contained in



 <architecture_AIX_level> = powerpc-ibm-aix5.1.0.0
                         or powerpc-ibm-aix5.2.0.0
                         or powerpc-ibm-aix5.3.0.0
                         or powerpc-ibm-aix6.1.0.0
                         or powerpc-ibm-aix7.1.0.0                                


 <GCC_Level> = your GCC version, e.g., 4.7.2

In this directory (<prefix>) you find the runtime libraries for the following cases:

  • 32-bit compilation, non-thread-safe (<prefix>)
  • 32-bit compilation, thread-safe (<prefix>/pthread)
  • 64-bit compilation, non-thread-safe (<prefix>/ppc64)
  • 64-bit compilation, thread-safe (<prefix>/pthread/ppc64)
So in order to not have a fixed version-specific runtime library search path contained in your binary you should use a generic search path like /opt/freeware/lib (for 32-bit shared libraries (mostly)) and /opt/freeware/lib/64 (for 64-bit shared libraries).


  • If you use such a generic search path, though, you need symbolic links from /opt/freeware/lib and /opt/freeware/lib64 to the specific GCC version that you have installed!
  • This works fine until you change (e.g., update) the GCC version, e.g., <prefix> changes
  • If the GCC version is changed these symbolic links must also be updated.


  • As a consequence, all newer GCC RPM packages contain the following symbolic links to the four runtime libraries listed above (here as an example I only show it for libgcc_s.a):
    • /opt/freeware/lib/libgcc_s.a -> <prefix>/libgcc_s.a, 32-bit non-thread-safe
    • /opt/freeware/lib64/libgcc_s.a -> <prefix>/ppc64/libgcc_s.a, 64-bit non thread-safe
    • /opt/freeware/lib/pthread/libgcc_s.a -- <prefix>/pthread/libgcc_s.a, 32-bit, thread-safe
    • /opt/freeware/lib/pthread/ppc64/libgcc_s.a -> <prefix>/pthread/ppc64/libgcc_s.a, 64-bit thread-safe
  • Whenever the GCC RPM packages are updated these symbolic links are also updated as part of the RPM package.
  • Consequences for 64-bit compilation:
    • Your $CFLAGS must contain "-L/opt/freeware/lib64 -L/opt/freeware/lib" in that order!
    • Your $LDFLAGS must contain "-Wl,-blibpath:/opt/freeware/lib64:/opt/freeware/lib" in that order!
Edit - History - Print - Recent Changes - Search
Page last modified on January 28, 2013, at 09:10 AM