Introduction to GCC

The GCC package contains GNU compilers. This is useful for compiling programs written in Ada, C, C++, Fortran, Java and Objective C.

Package information

Installation of GCC

If you plan to compile Ada, you will need to install GNAT temporarily to satisfy the circular dependency when you recompile GCC to include Ada.

Package information

GNAT dependencies



Installation of GNAT

Install GNAT by running the following commands:


The above script will ask you how and where you would like to install GNAT. To avoid conflicts with the system gcc, the package will be installed in a separate directory, that can later be removed from the system.

In response to the questions asked by the doconfig script, enter 3 in response to the first question and /opt/gnat in response to the second question.

To finish the install, run:


The GNAT compiler can be invoked by executing the gcc binary installed by the above script.

Return to Installation of GCC

Patch the source files with the following command:

patch -Np1 -i ../gcc-3.3.3-no_fixincludes-1.patch &&
sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in

Install GCC by running the following commands:

export PATH=/opt/gnat/bin:$PATH &&
cd gcc/ada &&
touch treeprs.ads [es]info.h nmake.ad[bs] &&
cd ../.. &&
mkdir ../gcc-build &&
cd ../gcc-build &&
CC=/usr/bin/gcc ../gcc-3.3.3/configure --prefix=/usr --enable-shared \
    --enable-languages=c,c++,objc,f77,ada,java --enable-threads=posix \
    --enable-__cxa_atexit --enable-clocale=gnu &&
make bootstrap &&
make -C gcc gnatlib_and_tools &&
make -k check &&
make install &&
ln -sf ../usr/bin/cpp /lib &&
ln -sf gcc /usr/bin/cc &&
ln -sf g77 /usr/bin/f77 &&

You may remove the GNAT installation:

rm -rf /opt/gnat

Command explanations

PATH_HOLD=$PATH: This command stores your current path before it's modified so that it can be restored after installation.

export PATH=/opt/gnat/bin:$PATH: This command allows the build to find GNAT's Ada compiler to build Ada.

touch treeprs.ads [es]info.h nmake.ad[bs]: This command creates necessary files for the Ada build. This step may be skipped if you don't want to compile the Ada front end.

CC=/usr/bin/gcc: This command works around the new PATH which puts GNAT 's gcc as the primary compiler.

--enable-languages=c,c++,objc,f77,ada,java: This command builds all available languages in the GCC package. You may modify this command to remove unwanted languages.

--enable-shared --enable-threads=posix --enable-__cxa_atexit: These commands are required to build the C++ libraries to published standards.

--enable-clocale=gnu: This command is a failsafe for incomplete locale data.

make gnatlib_and tools: This command completes the Ada build process. Skip this step if you have not enabled Ada as one of the languages.


The GCC package contains c++, c++filt, cpp, g++, g77, gcc, gccbug, gcov, glob, gnat, gnatbind, gnatbl, gnatchop, gnatfind, gnatkr, gnatlink, gnatls, gnatmake, gnatprep, gnatpsta, gnatpsys, gnatxref and GCC libraries.


The programs and libraries whose descriptions are missing here have been described in the LFS GCC-3.3.3 page.


g77 is the Fortran compiler invoked by gcc.


add2line converts the ASCII form of the 2-line orbital elements in a file to binary form and appends them to the orbdata files.


gcov is a test coverage program.


gdb is the GNAT debugger.


gnatbind is used to bind compiled objects.


gnatbl is the Ada linker.


gnatchop is useful for renaming files to meet the standard Ada default file naming conventions.


gnatelim is used to detect and eliminate unused subprograms in an Ada partition.


gnatfind is the GNAT definition/use finder.


gnatgcc is the compiler.


gnathtml.pl converts Ada source files to HTML for viewing in Web browsers.


gnatkr is used to determine the crunched name for a given file, when crunched to a specified maximum length.


gnatlink is used to link programs and build an executable file.


gnatls is the compiled unit browser.


gnatmake is an automatic make facility.


gnatmem is the GNAT utility that monitors dynamic allocation and deallocation activity in a program.


gnatprep is the GNAT external preprocessor.


gnatpsta determines the values of all the relevant parameters in Standard and outputs to stdout.


gnatpsys determines the values of all the relevant parameters in System and outputs to stdout.


gnatstub is a generator of body stubs.


gnatxref is the GNAT cross-referencer.


gvd is the GNU Visual Debugger.