Install GCC: Difference between revisions
No edit summary |
No edit summary |
||
| Line 3: | Line 3: | ||
This tutorial is based on [http://gcc.gnu.org/install/ this other guide]. |
This tutorial is based on [http://gcc.gnu.org/install/ this other guide]. |
||
The typical need is that in older systems GCC 4 is not available while GCC 3 is. (Of course we can use GCC 3 to compile GCC 4.) |
The typical need is that in older systems GCC 4 is not available while GCC 3 is. (Of course we can use GCC 3 to compile GCC 4.) |
||
You can check which version of GCC is currently installed by running |
|||
$gcc -v |
|||
... |
|||
gcc version 3.4.6 20060404 (Red Hat 3.4.6-3) |
|||
= Preparation = |
= Preparation = |
||
Revision as of 06:27, 1 March 2009
GCC stands for GNU Compiler Collection. The tutorial is focused in obtaining 'g++' (GNU C++) among all the available compilers in the collection. This tutorial is based on this other guide. The typical need is that in older systems GCC 4 is not available while GCC 3 is. (Of course we can use GCC 3 to compile GCC 4.)
You can check which version of GCC is currently installed by running
$gcc -v ... gcc version 3.4.6 20060404 (Red Hat 3.4.6-3)
Preparation
The tutorial assumes that you want to install GCC/g++ in your userspace directories (i.e. in your home directory).
Download the sources to a local directory:
mkdir ~/soft cd ~/soft wget http://gcc.releasenotes.org/releases/gcc-4.3.3/gcc-g++-4.3.3.tar.gz tar -zxvf gcc-g++-4.3.3.tar.gz
Also you will need the GMP library whose development (sources) are not installed in general (and in particular not in wcr). In normal cases I would give the instructions to compile and install GMP here but fortunately you can just put the GMP source inside GCC sources and that will allow to compile both at the same time.
cd ~/soft wget ftp://ftp.gnu.org/gnu/gmp/gmp-4.2.4.tar.gz tar -zxvf gmp-4.2.4.tar.gz mv gmp-4.2.4/* gcc-4.3.3/
Compilation
Everything will be installed in ~/usr, including the executable compilers in ~/usr/bin and the library files in ~/usr/lib. To specify that you do
cd ~/usr/gcc-4.3.3-build ../gcc-4.3.3/configure --prefix=$HOME/usr --with-local-prefix=$HOME/usr/local
It is important to check that the configure works (if it doesn't report it in this wiki) before doing
make
Then
make test-g++
to test that the compilation was succesfull and then do the final install:
make install