Compiling with Red Hat Linux 6

Red Hat Linux 6 offers the ability to compile against the 2.0 libraries used for Red Hat 5.2. The full details are at http://www.redhat.com/support/wpapers/glibccompat/ and are quite complete. To begin, several RPMs are needed:

compat-binutils-5.2
compat-glibc-5.2
compat-libs-5.2
compat-egcs-5.2
compat-egcs-c++-5.2[6]

Then compiling the desired code will be a matter of using the correct gcc to compile. By default, gcc will be the system's original gcc; if you want to compile with the compatability libraries, you'll need to use the i386-glibc20-linux-gcc compiler located in /usr/bin. Be careful that you do not find yourself using the standard gcc (also called i386-redhat-linux-gcc). By defining a link to /usr/bin/i386-glibc20-linux-gcc in the directory /usr/i386-glibc20-linux/bin directory (using the name gcc) and defining the path appropriately, this problem can be avoided, since gcc will be searched in /usr/i386-glibc20-linux/bin first and found there instead of finding /usr/bin/gcc.

The full details on using Red Hat 6 to compile C programs and C++ programs for glibc 2.0 under Red Hat Linux 6.0 are included on the web site.

In short, compiling a C program entails two things: making sure that the special gcc binary is used, and also that the specially made utilities are used (by setting the PATH). For many projects, the following program will be enough (if used to run other programs like make or configure):

#!/bin/ksh
env PATH=/usr/i386-glibc20-linux/bin:$PATH \
CC=i386-glibc20-linux-gcc "$@"

When using make with the compatabile libraries, it is a good idea to use the -e option: this forces the CC environment variable to override any CC variable contained in the Makefile. In this situation, this is a Good Thing.

However, there are many problems that will appear while using a system such as this. It is still easier and less prone to errors if a complete environment such as Debian 2.1 is used.

Compiling a C++ program requires more steps than detailed here; see Red Hat's web site for that information.



[6] Only needed for compiling C++ programs.