Install GCC first need GMP, MPFR, MPC these three libraries, can download the corresponding compression package from ftp://gcc.gnu.org/pub/gcc/infrastructure/. Because MPFR rely on GMP, and the MPC relies on GMP and MPFR, so first install GMP, followed by MPFR, the final is the MPC. The three libraries I use here are gmp4.3.2,mpfr2.4.2 and mpc0.8.1 respectively.
gmp-4.3.2.tar.bz2
mpfr-2.4.2.tar.bz2
Mpc-0.8.1.tar.gz
gcc-4.9.2.tar.bz2
After decompression, install separately
#安装gmp -4.3.2
$ tar jxf gmp-4.3.2.tar.bz2
$ CD gmp-4.3.2
$./configure--prefix=/home/zhw/developmentkits/gmp-4.3.2
$make
$make Install
$make Clean
$CD.
#安装mpfr -2.4.2
$ tar jxf mpfr-2.4.2.tar.bz2
$ CD mpfr-2.4.2
$./configure--prefix=/home/zhw/developmentkits/mpfr-2.4.2--with-gmp=/home/zhw/developmentkits/gmp-4.3.2
$make
$make Install
$make Clean
$CD.
#安装mpc -0.8.1
$ tar zxf mpc-0.8.1.tar.gz
$ CD mpc-0.8.1
$./configure--prefix=/home/zhw/developmentkits/mpc-0.8.1--with-gmp=/home/zhw/developmentkits/gmp-4.3.2-- with-mpfr=/home/zhw/developmentkits/mpfr-2.4.2
$ make
$ make Install
$ make clean
$CD.
Download gcc installer on http://gcc.gnu.org/index.html gcc-4.9.2.tar.bz2
$tar ZXF gcc-4.9.2.tar.bz2
$CD gcc-4.9.2
$./configure--prefix=/home/zhw/developmentkits/gcc-4.9.2--enable-threads=posix--disable-checking-- Disable-multilib--enable-languages=c,c++--with-gmp=/home/zhw/developmentkits/gmp-4.3.2--with-mpfr=/home/zhw/ developmentkits/mpfr-2.4.2--with-mpc=/home/zhw/developmentkits/mpc-0.8.1
Make
Make install
Make clean
Keep the old version of GCC and build symbolic links
Cd/usr/bin
Ln-s/USR/LOCAL/GCC-4.2.3/BIN/GCC gcc42
Ln-s/usr/local/gcc-4.2.3/bin/g++ g42++
Finally, add the following two lines of code to the/etc/profile:
ld_library_path=:/usr/local/mpc-0.8.1/lib:/usr/local/gmp-4.3.2/lib:/usr/local/mpfr-2.4.2/lib:/usr/local/ Gcc-4.2.3/lib
Export Ld_library_path
Re-login test to see if it can be used.
The above command can be written with a shell file, installgcc.sh, batch execution
Assume that all 4 downloaded installation files are placed under/software
#!/bin/sh
Cd/software
BUNZIP2 gmp-4.3.2.tar.bz2
Tar XF Gmp-4.3.2.tar
BUNZIP2 mpfr-2.4.2.tar.bz2
Tar XF Mpfr-2.4.2.tar
Tar zxf mpc-0.8.1.tar.gz
Tar zxf gcc-4.2.3.tar.gz
cd/software/gmp-4.3.2
./configure--prefix=/usr/local/gmp-4.3.2
Make
Make install
Make clean
cd/software/mpfr-2.4.2
./configure--prefix=/usr/local/mpfr-2.4.2--with-gmp=/usr/local/gmp-4.3.2
Make
Make install
Make clean
cd/software/mpc-0.8.1
./configure--prefix=/usr/local/mpc-0.8.1--with-gmp=/usr/local/gmp-4.3.2--with-mpfr=/usr/local/mpfr-2.4.2
Make
Make install
Make clean
Mkdir/software/gcc-build
Cd/software/gcc-build
.. /gcc-4.2.3/configure--prefix=/usr/local/gcc-4.2.3--enable-threads=posix--disable-checking--disable-multilib-- enable-languages=c,c++--with-gmp=/usr/local/gmp-4.3.2--with-mpfr=/usr/local/mpfr-2.4.2--with-mpc=/usr/local/ mpc-0.8.1
Make
Make install
Make clean
Cd/usr/bin
Ln-s/USR/LOCAL/GCC-4.2.3/BIN/GCC gcc42
Ln-s/usr/local/gcc-4.2.3/bin/g++ g42++