linux:centos gcc 升级 gcc-4.8.1

来源:互联网 发布:网络情歌 编辑:程序博客网 时间:2024/04/30 00:57

预备工作:

安装GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+

否则在第一步配置的时候报如下错误:
configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify


下载文件:mpc-1.0.3.tar.gz    gmp-5.0.1.tar.bz   mpfr-3.1.3.tar.gz
mkdir -p  gmp/build
mkdir -p  mpfr/build
mkdir -p  mpc/build
[root@localhost build]# mv -f /home/neko/Desktop/gmp-5.0.1.tar.bz -t ~/gmp/
[root@localhost build]# mv -f /home/neko/Desktop/mpfr-3.1.3.tar.gz -t ~/mpfr/
[root@localhost build]# mv -f /home/neko/Desktop/mpc-1.0.3.tar.gz -t ~/mpc/
[root@localhost build]# cd ./gmp/
[root@localhost build]# cd ./build/
[root@localhost build]# ../gmp-5.0.1/configure --prefix=/usr/local/gmp-5.0.1

[root@localhost build]#cd ./mpfr/
[root@localhost build]# cd ./build/
[root@localhost build]# ../mpfr-3.1.3/configure --prefix=/usr/local/mpfr-3.1.3 --with-gmp=/usr/local/gmp-5.0.1
[root@localhost build]# make && make install

[root@localhost build]# cd ~
[root@localhost ~]# cd ./mpc/
[root@localhost mpc]# ls
build  mpc-1.0.3.tar.gz
[root@localhost mpc]# tar zxf mpc-1.0.3.tar.gz 
[root@localhost mpc]# cd mpc-1.0.3
[root@localhost mpc-1.0.3]# cd ../build/
[root@localhost build]# ../mpc-1.0.3/configure --prefix=/usr/local/mpc-1.0.3 --with-gmp=/usr/local/gmp-5.0.1 --with-mpfr=/usr/local/mpfr-3.1.3

最后:
[root@localhost ~]# vim /etc/profile
在文件末尾添加:
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc-1.0.3/lib:/usr/local/gmp-5.0.1/lib:/usr/local/mpfr-3.1.3/lib
export LD_LIBRARY_PATH
添加后关闭终端,重启终端,这种添加是永久生效

或者立刻生效:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc-1.0.3/lib:/usr/local/gmp-5.0.1/lib:/usr/local/mpfr-3.1.3/lib
当终端关闭后就需要再次调用export命令生效!

1.下载源码包:gcc-4.8.1.tar.gz

mkdir gcccd gccmv /path/to/gcc-4.8.1.tar.gz .tar zxf gcc-4.8.1.tar.gz
mkdir build
cd build
[root@localhost build]#  ../gcc-4.8.1/configure -enable-checking=release -enable-languages=c,c++ -disable-multilib --with-gmp=/usr/local/gmp-5.0.1/ --with-mpfr=/usr/local/mpfr-3.1.3/ --with-mpc=/usr/local/mpc-1.0.3/ --prefix=/usr/local/<span style="font-family: Arial, Helvetica, sans-serif;">gcc-4.8.1</span>
[root@localhost build]# make && make install

2.如果出现libstdc++.so 静态库找不到的话

locate libstdc++.so#查询到对应的路径

make LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/gcc/i686-redhat-linux/4.4.4/libstdc++.so


0 0
原创粉丝点击