Next Previous Contents

8. Installing the GNU C and C++ compilers

This HOWTO used to install the C++ compiler from source, but that has been changed and is an exception. The C++ compiler is installed using pre-compiled binaries. The reason is that I have not been able to find the sources for the C++ compiler version that I prefer to use. So until then we'll use pre-compiled binaries.

We also will link the C compiler statically. Although Glibc is installed on our LFS system, we still are compiling the compiler on our normal Linux system. The normal Linux system may contain a different version of Glibc and the compiler will be linked against that version. Therefore we will link the compiler statically and later on when all statically linked software is being re-installed we also will re-install the compiler. This procedure is not necessary if both your normal Linux system and the LFS system use the same Library version, but since I don't know that we will do it this way.

8.1 Installing GCC 2.7.2.3

./configure
make LANGUAGES=c
make stage1 
make CC="stage1/xgcc -Bstage1/" CFLAGS="-g -O2" LDFLAGS=-static LANGUAGES=c
make stage2
make CC="stage2/xgcc -Bstage2/" CFLAGS="-g -O2" LDFLAGS=-static LANGUAGES=c
make compare

Please note that you will see errors during the "make stage1" and "make stage2" processes regarding files not being found. This is perfectly ok, as these errors are c++/objc/g77 compiler related files. We specify that we only want to install the C compiler, so you'll get those errors.

8.2 Installing the g++_2.91.66-0slink2.deb package

Note that this g++ compiler is already pre-compiled and linked against glibc 2.0.7. Therefore there is no need to re-install this package in a later stage.

8.3 Creating necessary symlinks

The system needs a few symlinks to ensure every program is able to find the compiler. Some programs run the 'cc' program, others run the 'gcc' program, some programs expect the cpp program to be in /lib (which is /usr/lib on the LFS system) and others expect to find it in /usr/bin.

cd $LFS/usr/lib; ln -s gcc-lib/<host>/2.7.2.3/cpp cpp
cd $LFS/usr/bin
ln -s ../lib/gcc-lib/<host>/2.7.2.3/cpp cpp
ln -s gcc cc

Replace <host> with the directory where the gcc-2.7.2.3 files were installed (i686-unknown-linux in my case). You will most likely find two different directories. One of these is i484-linux. This is the directory that contains the C++ compiler files that we installed before. The directory for the gcc compiler will probably have a different name.


Next Previous Contents