White Paper: GNU C Library Compatibility Environment


< Prev Contents Next >

Building programs

Building compatible C programs
The compat series of packages essentially provide a cross compiling environment. To use the system you will need the following packages:

compat-binutils-5.2
compat-egcs-5.2
compat-glibc-5.2
compat-libs-5.2

To build a binary using the system, you will use i386-glibc20-linux-gcc instead of gcc as the compiler.

[msw@rhl60 msw]$ i386-glibc20-linux-gcc -o hello hello.c

This new binary can be transferred to a Red Hat Linux 5.2 box and it will successfully execute:

[msw@rhl52 msw]$ ./helloHello, world!

In most cases entire applications can be rebuilt by editing a toplevel Makefile to use the correct gcc. Applications which use the autoconf system for configuration are usually easy to cross compile. To do this run configure like this:

env PATH=/usr/i386-glibc20-linux/bin;$PATH \
    CC=i386-glibc20-linux-gcc ./configure

Once the package has been configured, running make will build binaries compatible with glibc 2.0.

Building compatible C++ programs
C++ programs can also be built for 5.2 applications using this system. To build C++ programs the compat-egcs-c++-5.2 package must be installed in addition to the packages needed for C compiling.

Building C++ programs using the compatibility environment requires a little more work than building C programs. This is because you must provide the include path for the C++ headers to the compiler. Invoke the compatibility C++ compiler with:

env PATH="/usr/i386-glibc20-linux/bin;$PATH" \
i386-glibc20-linux-c++ -I /usr/i386-glibc20-linux/include/g++
You can provide the header include path to autoconf based packages by running configure with a few environment variables set:

env PATH=/usr/i386-glibc20-linux/bin;$PATH \
    CXX=i386-glibc20-linux-c++ \
    CXXFLAGS=-I/usr/i386-glibc20-linux/include/g++ ./configure

< Prev Contents Next >