5.8. Installing GCC on the LFS system

5.8.1. Installation of GCC on the LFS system

After you unpacked the gcc-2.95.2 archive don't enter the newly created gcc-2.95.2 directory but stay in the $LFS/usr/src directory. Install GCC by running the following commands:


mkdir $LFS/usr/src/gcc-build &&
cd $LFS/usr/src/gcc-build &&
../gcc-2.95.2/configure --prefix=/usr \
   --with-gxx-include-dir=/usr/include/g++ \
   --enable-languages=c,c++ --disable-nls &&
make -e LDFLAGS=-static bootstrap &&
make prefix=$LFS/usr local_prefix=$LFS/usr/local \
   gxx_include_dir=$LFS/usr/include/g++ install &&
cd $LFS/lib &&
ln -s ../usr/lib/gcc-lib/*/2.95.2/cpp cpp &&
cd $LFS/usr/lib &&
ln -s gcc-lib/*/2.95.2/cpp cpp &&
cd $LFS/usr/bin &&
ln -s gcc cc

5.8.2. Command explanations

--enable-languages=c,c++: This only builds the C and C++ compilers and not the other available compilers as they are, on the average, not often used. If you do need those other compilers don't use the --enable-languages parameter.

ln -s ../usr/lib/gcc-lib/*/2.95.2/cpp cpp: This creates the $LFS/lib/cpp symlink. Some packages explicitely try to find cpp in /lib.

ln -s ../usr/lib/gcc-lib/*/2.95.2/cpp cpp: This creates the $LFS/usr/lib/cpp symlink as there are packages that expect cpp to be in /usr/lib.

5.8.3. Contents

The GCC package contains compilers, preprocessors and the GNU C++ Library.

5.8.4. Description

5.8.4.1. Compiler

A compiler translates source code in text format to a format that a computer understands. After a source code file is compiled into an object file, a linker will create an executable file from one or more of these compiler generated object files.

5.8.4.2. Pre-processor

A pre-processor pre-processes a source file, such as including the contents of header files into the source file. You generally don't do this yourself to save yourself a lot of time. You just insert a line like #include <filename>. The pre-processor file insert the contents of that file into the source file. That's one of the things a pre-processor does.

5.8.4.3. C++ Library

The C++ library is used by C++ programs. The C++ library contains functions that are frequently used in C++ programs. This way the programmer doesn't have to write certain functions (such as writing a string of text to the screen) from scratch every time he creates a program.