下面安装脚本是针对gcc7.3的,其他版本也类似。
#!/bin/bash
install_dir="/your/install/dir"
mpc_zip="mpc-1.0.3.tar.gz"
gmp_zip="gmp-6.1.0.tar.bz2"
mpfr_zip="mpfr-3.1.4.tar.bz2"
gcc_zip="gcc-7.3.0.tar.gz"
mpc=${mpc_zip%%.tar*}
gmp=${gmp_zip%%.tar*}
mpfr=${mpfr_zip%%.tar*}
gcc=${gcc_zip%%.tar*}
install_dir=$install_dir"/"$gcc
if [[ ! -d "$install_dir" ]];then
mkdir $install_dir
fi
cur_dir=$PWD
cd $cur_dir
tar -jxvf $gmp_zip
cd $gmp
mkdir build
cd build
../configure --prefix=$install_dir/$gmp
make
make install
cd $cur_dir
tar -jxvf $mpfr_zip
cd $mpfr
mkdir build
cd build
../configure --prefix=$install_dir/$mpfr --with-gmp=$install_dir/$gmp
make
make install
cd $cur_dir
tar -zxvf $mpc_zip
cd $mpc
mkdir build
cd build
../configure --prefix=$install_dir/$mpc --with-gmp=$install_dir/$gmp --with-mpfr=$install_dir/$mpfr
make
make install
export LD_LIBRARY_PATH=$install_dir/$mpfr/lib:$install_dir/$gmp/lib:$install_dir/$mpc/lib:$LD_LIBRARY_PATH
export C_INCLUDE_PATH=$install_dir/$mpfr/include:$install_dir/$gmp/include:$install_dir/$mpc/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=
cd $cur_dir
tar -zxvf $gcc_zip
cd $gcc
mkdir build
cd build
../configure --prefix=$install_dir --enable-threads=posix --disable-checking --disable-multilib --enable-languages=c,c++ --with-gmp=$install_dir/$gmp --with-mpfr=$install_dir/$mpfr --with-mpc=$install_dir/$mpc
make -j8
make install