第一步:准备好安装包(gmp 、mpfr 、mpc、gcc+)
下载地址:http://ftp.gnu.org/gnu/gcc/gcc-4.5.1/gcc-4.5.1.tar.bz2
可以去https://gcc.gnu.org/pub/gcc/infrastructure/下载依赖包(gmp-4.3.2.tar.bz2,mpc-1.0.3.tar.gz,mpfr-3.1.4.tar.bz2)
第一步:安装依赖包(GMP 、gmp 、mpfr 、mpc)
安装gmp-4.3.2
#tar jxvf gmp-4.3.2.tar.bz2
#mkdir /usr/local/gmp-4.3.2
#cd /usr/local/gmp-4.3.2
#/opt/gmp-4.3.2/configure -–prefix=/usr/local/gmp-4.3.2
#make
make install
安装mpfr3.1.4
#tar jxvf mpfr-3.1.1.tar.bz2
#mkdir /usr/local/mpfr-3.1.4
#cd /usr/local/mpfr-3.1.4
#/opt/mpfr-3.1.1/configure --prefix=/usr/local/mpfr-3.1.4 --with-gmp=/usr/local/gmp-4.3.2
#make
#make install
安装mpc-1.0.3
#tar –xf mpc-1.0.3.tar.gz
#mkdir /usr/local/mpc-1.0.3
#cd /usr/local/mpc-1.0.3
#/opt/mpc-1.0.3/configure --prefix=/usr/local/mpc-1.0.3 --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr2.4.2
#make
#make install
第三步:调价环境变量
#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc-1.0.3/lib:/usr/local/gmp-4.3.2/lib:/usr/local/mpfr-3.1.4/lib
安装gcc-4.5.1
#cd /usr/local/gcc-4.5.1
#/opt/gcc-5.3.0/configure --prefix=/usr/local/gcc-4.5.1 -enable-threads=posix -disable-checking -disable-multilib -enable-languages=c,c++ --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-3.1.4 --with-mpc=/usr/local/mpc-1.0.3
#make
#make install
#gcc -v ####验证安装是否正确
注意:常见故障
error while loading shared libraries: libmpc.so.3
检查环境变量LD_LIBRARY_PATH是否存在且正确,如果不正确或者不存在,请创建该环境变量
#export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc-1.0.3/lib:/usr/local/gmp-4.3.2/lib:/usr/local/mpfr-3.1.4/lib