Gcc版本手动编译升级

[root@localhost yilai]# gcc --version

安装gmp-4.3.2

[root@localhost gcc-build]#tar -xjvf gmp-4.3.2.tar.bz2

[root@localhost gcc-build]# cd gmp-4.3.2

[root@localhost gcc-build]#mkdir gmp-build

[root@localhost gcc-build]#cd gmp-build

[root@localhost gcc-build]#../configure --prefix=/usr/local/gmp-4.3.2

[root@localhost gcc-build]#make

[root@localhost gcc-build]#make install

安装mpfr-2.4.2 

[root@localhost gcc-build]#tar -xjvf mpfr-2.4.2.tar.bz2

[root@localhost gcc-build]#cd mpfr-2.4.2

[root@localhost gcc-build]#mkdir mpfr-build

[root@localhost gcc-build]#cd mpfr-build

[root@localhost gcc-build]#../configure --prefix=/usr/local/mpfr-2.4.2 --with-gmp=/usr/local/gmp-4.3.2

[root@localhost gcc-build]#make

[root@localhost gcc-build]#make install

安装mpc-0.8.1.tar.gz

[root@localhost gcc-build]#tar -xzvf mpc-0.8.1.tar.gz

[root@localhost gcc-build]#cd mpc-0.8.1

[root@localhost gcc-build]#mkdir mpc-build

[root@localhost gcc-build]#cd mpc-build

[root@localhost gcc-build]#../configure --prefix=/usr/local/mpc-0.8.1 --with-gmp=/usr/local/gmp-4.3.2 --with-mpfr=/usr/local/mpfr-2.4.2

[root@localhost gcc-build]#make && make install

添加环境变量

[root@localhost mpc-build]# vim /etc/profile

LD_LIBRARY_PATH加入以下内容

:/usr/local/gmp-4.3.2/lib:/usr/local/mpc-0.8.1/lib:/usr/local/mpfr-2.4.2/lib:/usr/local/gcc-5.4.0/lib 

安装gcc-5.4.0

[root@localhost gcc-build]#tar -xzvf gcc-5.4.0.tar.gz

[root@localhost gcc-build]#cd gcc-5.4.0

[root@localhost gcc-build]#mkdir gcc-build

[root@localhost gcc-build]#cd gcc-build

[root@localhost gcc-build]#../configure --prefix=/usr/local/gcc-5.4.0 --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

[root@localhost gcc-build]#make && make install

执行该编译时间非常长,超过2小时。

备份旧版本

[root@localhost gcc-build]# mv /usr/bin/gcc gcc_4.8.5back

[root@localhost gcc-build]# mv /usr/bin/g++ g++_4.8.5back

调用新版本

[root@localhost gcc-build]# ln -s /usr/local/gcc-5.4.0/bin/gcc /usr/bin/gcc

[root@localhost gcc-build]# ln -s /usr/local/gcc-5.4.0/bin/g++ /usr/bin/g++

查看更新版本

[root@localhost gcc-build]# gcc -v

 

posted @ 2019-08-09 17:07  努力跑在岁月之前  阅读(939)  评论(0编辑  收藏  举报