Compiling and linking with libc5 under Red Hat Linux 5.0/Intel or later

George B. Moody, george@mit.edu

v1.8, 4 February 2002 (links updated 11 April 2003)


Many applications don't work properly when compiled using glibc (libc6) under Red Hat Linux (RHL) 5.0 or later versions. Although the older libc5 libraries are provided with RHL 5.x and 6.x, their use is limited to supporting old binaries; as delivered, it is not possible to create binaries linked to libc5 under these versions of Red Hat Linux. This document shows how to do so, without affecting the usual process of compiling and linking with glibc.

Please read the updated information below if you are using Red Hat Linux 6.0 or 6.1!

Thanks to Andi Thul, who points out that the ld.so-1.9.5-5 and libc-5.3.12-28 packages are no longer archived by Red Hat at the original locations. Copies of these packages can now be downloaded from this site by following the links below.

Sorry, I am no longer maintaining this package, and I have no information on using it with later versions of Red Hat Linux, but I will update this document based on reports from users as long as there is any interest.

Adrian Bunk (Debian maintainer of libc5) writes:

In Debian on the i386 architecture a user simply has to install the packages altgcc and libc5-altdev (that are in the distribution) to find a fully working gcc for libc5 in /usr/i486-linuxlibc1/bin/ . This works in all stable releases including Debian 2.2 (potato) and will still work in the next release of Debian.

A frequent question on Red Hat's hurricane-list and other RH mailing lists asks how to compile and link to libc5 under RHL 5.0, but I have seen no clear answers. Responses are often variations on the theme of ``well-written software should compile properly with glibc.'' Of course, your programs and mine are invariably well-written, but (in moments of weakness) many of us have succumbed to the temptation to use large libraries, such as Motif or XView, that ... how to say this ... are just not quite up to this standard. (OK, the sources look like line noise phonetically transcribed into pig Latin, and I stopped reading after the first 10 megabytes, so perhaps I missed something.) Those of us who have other things to do in the next month or two may consider the task of converting these libraries into well-written software to be a bit off-track, and a pragmatic solution would be helpful. The Glibc2-HOWTO gives a few clues but is missing crucial details.

To remedy this limitation on RHL 5.0/Intel systems, download and install gcc5-1.0-1.i386.rpm (about 2.5 Mb), which includes:

/usr/bin/gcc5

a script that invokes the gcc version 2.7.2.1 compiler that was included with RHL 4.2

/usr/bin/ldd5

a replacement for the GNU ldd 2.0.7 supplied with RHL 5.0; this version correctly resolves links for binaries linked with either glibc or libc5 (the standard version gives incomplete and often bogus information for libc5-based binaries)

/usr/i486-linux-libc5/include

a copy of the RHL 4.2 /usr/include tree, needed by gcc5

/usr/i486-linux-libc5/lib/[g]crt*.o

run-time start-up files linked with all executables (from /usr/lib in RHL 4.2)

/usr/i486-linux-libc5/lib/lib*.so

symbolic links to libc.so.5, libm.so.5, libX11.so.6, etc. The targets of these links are included in RHL 5.0, but the links themselves are missing. These links are needed only at compilation time, not at execution time. Thus their omission from RHL 5.0 does not affect the use of existing libc5-based binaries, but makes it impossible to create new binaries linked to libc5, libm5, etc.

/usr/lib/gcc-lib/i486-linux-libc5/2.7.2.1

a copy of the RHL 4.2 /usr/lib/gcc-lib/i386-linux/2.7.2.1 tree, needed by gcc5 (note the name change)

You will also need to have ld.so-1.9.5-5, and it's a good idea to have libc-5.3.12-28 as well (presumably later versions would also work, but these versions are known to work). Recent copies of the RHL 5.0 CD-ROMs may include these packages. If yours is an early copy, you can obtain these packages from this site (download and install ld.so-1.9.5-5.i386.rpm and libc-5.3.12-28.i386.rpm).

The md5sums of these packages are:
cde9e6b9925fe5bf50ff09cf4b8ac07b gcc5-1.0-1.i386.rpm
f0cbf7b47712d58c1f39c694939a86be ld.so-1.9.5-5.i386.rpm
7d0a39ca1d40c5b4501bd5f8020e76bb libc-5.3.12-28.i386.rpm

(Newer versions of the last two of these packages are available here:
ef41819eed40143b048b988138d99cdf ld.so-1.9.5-13.i386.rpm
e540ab65530070175887a6fa7096541b libc-5.3.12-31.i386.rpm
These versions should be compatible with gcc5-1.0-1 but have not been tested; please let me know if they work for you.)

To compile and link a program to libc5, simply use gcc5 instead of gcc. In most cases, if you are using make to manage compilation, you can either:

Warning: don't try to install gcc5 as gcc; this won't work, since gcc5 itself is a script that invokes the real gcc.

You can verify that everything is working properly by compiling a program using gcc5 to generate an executable, and then using a command of the form

LD_TRACE_LOADED_OBJECTS=1 foo

or simply

ldd5 foo

(replacing foo by the name of the executable) to check its dependencies. GNU ldd 2.0.7, supplied with RHL 5.0, attempts to do this, but it doesn't know where to find libc5, or any other libc5-compatible libraries; if you use that version of ldd on an executable linked to libc5, ldd reports ``libc.so.5 => not found'', and other libraries will be not found (or else they will be misreported if their sonames match those of glibc libraries). ldd5 is a replacement for GNU ldd 2.0.7 that I've modified so that it can handle both libc5- and glibc-based binaries; this is installed as /usr/bin/ldd5 when you install gcc5.

If your program needs a libc5-compatible library other than those provided with RHL 5.0 in /usr/i486-linux-libc5/lib, the solution is to get this library (from RHL 4.2 or another source) and install it in /usr/i486-linux-libc5/lib, together with a lib*.so symbolic link pointing to it. The gcc5 package already includes such a link for libXm.so.2, the Motif library; if you need a libc5-compatible libXm.so.2, however, you will need to get it and install it in /usr/i486-linux-libc5/lib yourself, since it is not included with RHL 5.0 or in the gcc5 package. RHL 5.0 provides two versions of several other libraries in /usr/i486-linux-libc5/lib; in such cases, you should choose which versions you wish to use when compiling with gcc5, and make lib*.so links for those versions as required.

If you have all of the necessary RHL 4.2 files and just need the gcc5 script, here it is:

#!/bin/bash
export GCC_EXEC_PREFIX=/usr/i486-linux-libc5/lib/
gcc -b i486-linux-libc5/2.7.2.1 \
            -I/usr/i486-linux-libc5/include \
            -I/usr/lib/gcc-lib/i486-linux-libc5/2.7.2.1/include \
            -L /usr/lib/gcc-lib/i486-linux-libc5/2.7.2.1 "$@"

Note for RHL 6.1 users

A group of users of this package at INRIA Rhône-Alpes has kindly provided the information contained in this section (and much of the following section for RHL 6.0).

Two problems occur when using this package under RHL 6.1: