gcc的安装需要gmp,mpfr和mpc三个库。mpfr依赖gmp,mpc依赖gmp和mpfr,因此要先安装gmp,其次mpfr,最后mpc。
在http://ftp.gnu.org/gnu/各个目录下可以下载三个库的最新版本。到2014年12月11日,这三个库最新的版本分别为gmp-6.0.0,mpfr-3.1.2,mpc-1.0.2
我们把这几个软件安装在/opt/目录下
第一步,首先安装gmp-6.0.0
#tar –jxf gmp-6.0.0.tar.bz2
#cd gmp-6.0.0
#./configure --prefix=/opt/gmp-6.0.0
#make
#make install
第二步,然后安装mpfr-3.1.2
#tar –jxf mpfr-3.1.2.tar.bz2
#cd mpfr-3.1.2
#./configure --prefix=/opt/mpfr-3.1.2
--with-gmp=/opt/gmp-6.0.0
#make
#make install
第三步,然后安装mpc-1.0.2
#tar –xzf mpc-1.0.2.tar.gz
#cd mpc-1.0.2
#./configure --prefix=/opt/mpc-1.0.2
--with-gmp=/opt/gmp-6.0.0 --with-mpfr=/opt/mpfr-3.1.2
#make
#make install
第四步,添加环境变量
#export
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/mpc-1.0.2/lib:/opt/mpfr-3.1.2/lib:/opt/gmp-6.0.0/lib
第五步,安装gcc-4.9.2
#tar –jxf gcc-4.9.2.tar.bz2
#cd gcc-4.9.2
#./configure –prefix=/opt/gcc-4.9.2
–enable-threads=posix --with-mpc=/opt/mpc-1.0.2 --with-gmp=/opt/gmp-6.0.0 --with-mpfr=/opt/mpfr-3.1.2
#make
#make install
第六步,建立软链接
#ln /opt/gcc-4.9.2/bin/gcc gcc
#ln /opt/gcc-4.9.2/bin/g++ g++
第七步,添加环境变量
打开/etc/bashrc文件或者打开/etc/profile添加代码如下
export PATH=$PATH:/opt/gcc-4.9.2/bin
export
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/mpc-1.0.2/lib:/opt/mpfr-3.1.2/lib:/opt/gmp-6.0.0/lib:/opt/gcc-4.9.2/lib64