How to install the latest GNU compilers
The GNU compilers consists of compilers for C, C++, Objective-C, Fortran, Ada, and Java. The following steps are those that I used for this installation.
If you are only interested in installing a C++ compiler, then follow the steps at the bottom of this page.
Note: These instructions assume that
you are familiar with unix/linux commands, that you have the
necessary privileges to write to various directories, that you have
access to commands, such as bunzip2, tar, and make, and that you
already have a C compiler installed. They also assume that you
will not encounter installation problems – that is not always a
safe assumption. Good luck.
- Download the file gcc-4.3.2.tar.bz2
- Unzip the file using the command:
bunzip2 gcc-4.3.2.tar.bz2
This will change the file to: gcc-4.3.2.tar
- Untar this file using the command:
tar xvf gcc-4.3.2.tar
This command will create a directory: gcc-4.3.2 and copy the necessary installation files into it.
- Change directory to the gcc-4.3.2 directory:
cd obj
- Create an obj directory:
mkdir obj
- Configure the installation files: ../configure
This command will create a
Makefile in the obj directory.
Note: During this installation, I experienced the following error message:
configure: error: Building GCC requires GMP 4.1+ and MPFR 2.3.0+.
Try the --with-gmp and/or --with-mpfr options to specify their locations.
Copies of these libraries' source code can be found at their respective
hosting sites as well as at ftp://gcc.gnu.org/pub/gcc/infrastructure/.
See also http://gcc.gnu.org/install/prerequisites.html for additional info.
If you obtained GMP and/or MPFR from a vendor distribution package, make
sure that you have installed both the libraries and the header files.
They may be located in separate packages.
I, then, installed the mpfr-devel package.
That solved the problem.
- Build the compiler: make
This will take a long time (30 minutes to 2 hours) to complete.
- Install the compiler (this command may require root privilege):
su root
make install
- Make sure the installation is OK:
g++ -v
This command should identify the version as 4.3.2.
This was the response after my installation:
/home/joe/download/gcc-4.3.2/obj> g++ -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../configure
Thread model: posix
gcc version 4.3.2 (GCC)
- Download the files gcc-core-4.3.3.tar.bz2 and gcc-c++-4.3.2.tar.bz2
- Unzip both files using the commands:
bunzip2 gcc-core-4.3.3.tar.bz2
and
bunzip2 gcc-c++-4.3.3.tar.bz2
This will change the files to: gcc-core-4.3.3.tar and gcc-c++-4.3.3.tar
- Untar these files using the commands:
tar xvf gcc-core-4.3.3.tar
and
tar xvf gcc-c++-4.3.3.tar
These commands will create a directory: gcc-4.3.3 and copy from both tar files the necessary installation files into it.
- Change directory to the gcc-4.3.3 directory:
cd gcc-4.3.3
- Create an obj directory:
mkdir obj
- Change directory to the obj directory:i
cd obj
- Configure the installation files: ../configure
This command will create a
Makefile in the obj directory.
- Build the compiler: make
This will take a long time (30 minutes to 2 hours) to complete.
- Install the compiler (this command may require root privilege):
su root
make install
- Make sure the installation is OK:
g++ -v
This command should identify the version as 4.3.3.
This was the response after my installation:
/home/joe> g++ -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../configure
Thread model: posix
gcc version 4.3.3 (GCC)