Install required Libraries
Sudo apt-Get install build-essential
Sudo apt-Get install zlibc
Sudo apt-Get install zlib1g-dev
Sudo apt-Get install M4
Sudo apt-Get install gcc-multilib
Obtain source code
Go to the/usr/src directory
Wget http://gcc.igor.onlinedirect.bg/releases/gcc-4.6.1/gcc-4.6.1.tar.bz2
Tar jxvf gcc-4.6.1.tar.bz2
Compile the dependent library GMP
Wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
Tar jxvf gmp-4.3.2.tar.bz2
Mkdir gmp_build
CD gmp_build
../Gmp-4.3.2/configure-Prefix =/usr/gmp-4.3.2
Make
Make check
Make install
Mpfr
Wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
Tar jxvf mpfr-2.4.2.tar.bz2
Mkdir mpfr_build
CD mpfr_build
../Mpfr-2.4.2/configure-Prefix =/usr/mpfr-2.4.2-with-GMP =/usr/gmp-4.3.2
Make
Make check
Make install
MPC
Wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz
Tar zxvf mpc-0.8.1.tar.gz
Mkdir mpc_build
CD mpc_build
../Mpc-0.8.1/configure-Prefix =/usr/mpc-0.8.1-with-GMP =/usr/gmp-4.3.2-with-mpfr =/usr/mpfr-2.4.2
Make
Make check
Make install
Compile gcc
Mkdir gcc_build
CD gcc_build
.. /Gcc-4.6.1/configure-Prefix =/usr/gcc-4.6.1-enable-threads = POSIX-Disable-checking-Disable-multilib-enable-versions ages = C, c ++-with-GMP =/usr/gmp-4.3.2-with-mpfr =/usr/mpfr-2.4.2-with-MPC =/usr/mpc-0.8.1
Export LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:/usr/mpc-0.8.1/lib:/usr/gmp-4.3.2/lib:/usr/mpfr-2.4.2/lib
Make
Apt-Get install dejagnu
Apt-Get install autogen
Make check
Make install
If compile error, can't find error. h In some files, use the following command:
Sudo ln-SV/usr/src/linux-headers-2.6.38-10/ARCH/x86/include/ASM/usr/include/ASM
Replace the old GCC version
The old version of GCC is in the/usr/bin directory.
CD/usr/bin
Mv gcc gcc_bk
MV g ++ _ BK
Mv cpp cpp_bk
Mv c ++ _ BK
Use the newest version
Ln-S/usr/gcc-4.6.1/bin/GCC/usr/bin/GCC
Ln-S/usr/gcc-4.6.1/bin/g + +/usr/bin/g + +
Ln-S/usr/gcc-4.6.1/bin/CPP/usr/bin/CPP
Ln-S/usr/gcc-4.6.1/bin/C ++/usr/bin/C ++
Add following into/etc/profile file
LD_LIBRARY_PATH =/usr/mpc-0.8.1/lib:/usr/gmp-4.3.2/lib:/usr/mpfr-2.4.2/lib:/usr/gcc-4.6.1/lib:/usr/lib
Export LD_LIBRARY_PATH