centos6.4编译gcc6.4
阅读原文时间:2023年07月08日阅读:1

#!/bin/bash
dir=$(pwd)
echo $dir

cd $dir
rm -rf gmp-6.1.
#wget https://gmplib.org/download/gmp/gmp-6.1.2.tar.xz
tar xvf gmp-6.1..tar.xz
cd gmp-6.1.
./configure --disable-shared --enable-static --prefix=$dir/extern
make && make install
echo "----------------gmp-6.1.2 over------------------"

cd $dir
rm -rf mpfr-3.1.
#wget https://www.mpfr.org/mpfr-3.1.6/mpfr-3.1.6.tar.gz
tar xvf mpfr-3.1..tar.gz
cd mpfr-3.1.
./configure --disable-shared --enable-static --prefix=$dir/extern --with-gmp=$dir/extern
make && make install
echo "----------------mpfr-3.1.6 over------------------"

cd $dir
rm -rf mpc-1.0.
#wget ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz
tar xvf mpc-1.0..tar.gz
cd mpc-1.0.
./configure --disable-shared --enable-static --prefix=$dir/extern --with-gmp=$dir/extern --with-mpfr=$dir/extern
make && make install
echo "----------------mpc-1.0.3 over------------------"

cd $dir
rm -rf gcc-6.4.
#wget ftp://ftp.gnu.org/gnu/gcc/gcc-6.4.0/gcc-6.4.0.tar.gz
tar xvf gcc-6.4..tar.gz
cd gcc-6.4.
./configure --prefix=$dir/bin --with-gmp=$dir/extern --with-mpfr=$dir/extern --with-mpc=$dir/extern --enable-checking=release --enable-languages=c,c++ --disable-multilib
make -j2
make install

编译好gcc6.4后 要使用的话 需要配置一下环境比如我的安装路径是/root/bin 下面的内容参考了这个地址https://www.cnblogs.com/succeed/p/6204438.html真是太感谢了

#!/bin/bash
gccDir=/root/bin
rm -f /etc/profile.d/gcc.sh
echo "export PATH=$gccDir/bin:\$PATH" >>/etc/profile.d/gcc.sh
source /etc/profile.d/gcc.sh
gcc -v
echo "----------gcc bin path ok-----------"

rm -f /usr/include/gcc
ln -sv $gccDir/include/ /usr/include/gcc
echo "----------gcc include path ok-----------"

rm -f /etc/ld.so.conf.d/gcc.conf
echo "$gccDir/lib64" >>/etc/ld.so.conf.d/gcc.conf
ldconfig -v >>out
rm -f out
ldconfig -p |grep gcc
echo "----------gcc lib64 path ok-----------"