48Chapter3 Compilers and Assemblers
3.2Installing GNU Compiler
In most cases, GCC comes with all Linux distributions. However you can download the latest
version, and build and install it according to your requirements. You may also need to build your
compiler if you are building a cross-compiling development system. The best way to build a new
version of the compiler is to have some pre-installed and pre-configured Linux distribution on
your system that will be used to build the new compiler. For the purpose of writing this book, we
have used Red Hat 7.1 but the process is the same on any distribution of Linux.
The installation process is done in multiple steps. After downloading, you have to untar
the source code and build it in a directory. This directory should be separate from the source
code directory tree. The building process includes configuration and compiling stages. Once you
have successfully created the new compiler, you can install it in a directory of your choice. It is
advised to keep this installation directory separate from the location where the original compiler
is installed.
3.2.1Downloading
You can download the latest version of GCC from ftp://ftp.gnu.org/gnu/gcc/. I down-
loaded GCC 3.0.4 and it is about 17.5 MB. You can also find a mirror site near you to get GCC.
A list of mirror sites is available on http://www.gnu.org/order/ftp.html.
3.2.2Building and Installing GCC
The GCC installation process can be divided into four steps for simplicity and understand-
ing.
1.
Download and extract
2.
Configure
3.
Build
4.
Install
3.2.2.1Download and Extract
First create a directory where you will unpack the source code. Use the
tar
command to
unpack the code. For our purpose, I have created a directory
/gcc3
to compile and build the
GCC compiler. The untar process looks like the following and it creates a directory
gcc-
3.0.4
under
/gcc3
directory.
[root@laptop /gcc3]# tar zxvf gcc-3.0.4.tar.gz
gcc-3.0.4/
gcc-3.0.4/INSTALL/
gcc-3.0.4/INSTALL/index.html
gcc-3.0.4/INSTALL/README
gcc-3.0.4/INSTALL/specific.html
gcc-3.0.4/INSTALL/download.html
gcc-3.0.4/INSTALL/configure.html
Next Page >>
<< Previous Page
Back to the Table of Contents