手动编译源码升级gcc4.8.2

来源:互联网 发布:淘宝服务器租用 编辑:程序博客网 时间:2024/05/16 07:25
1.下载下述4个软件包http://gcc.gnu.org/    http://gmplib.org/    http://www.mpfr.org/    http://www.multiprecision.org/
2. 解压安装:安装有先后顺序:GMP、MPFR、MPC、GCC
2.1 安装gmp

tar jxf gmp-*.*.*.tar.bz2

cd gmp-*.*.*/

./configure --prefix=/usr/local/gmp/

make

make install

2.2 安装MPFR:

cd ../

tar jxf mpfr-*.*.*.tar.bz2

cd mpfr-*.*.*/

./configure --prefix=/usr/local/mpfr --with-gmp=/usr/local/gmp

make

make install

2.3 安装MPC:

cd ../

tar xzf mpc-*.*.*.tar.gz

cd mpc-*.*.*

./configure --prefix=/usr/local/mpc --with-mpfr=/usr/local/mpfr --with-gmp=/usr/local/gmp

make

make install

3. vim /etc/profile 加入 export  LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/mpc/lib:/usr/local/gmp/lib:/usr/local/mpfr/lib
4. source /etc/profile
5. 安装gcc(安装c和c++的静态库: yum install glibc-static libstdc++-static -y  (保险起见))

5.1 cd ../

tar -jxvf gcc-*.*.*.tar.bz2

cd gcc-*.*.*

mkdir gcc-build-*.*.*

cd gcc-build-*.*.*

../configure --prefix=/usr/local/gcc --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++ --with-gmp=/usr/local/gmp --with-mpfr=/usr/local/mpfr --with-mpc=/usr/local/mpc

make

make install

6. 创建软连接
ln -s /usr/local/gcc/bin/gcc    /usr/bin/gcc  
ln -s /usr/local/gcc/bin/g++    /usr/bin/g++
7. 测试
gcc -v
0 0