# 先装几个用得到或者用不到的软件包
yum install -y binutils
yum install -y gzip gawk gmake tar
yum install -y perl // darwin
yum install -y zip unzip // libgcj
# 解压源码包并下载一些编译依赖项,在编译gcc时一同自动构建
tar -xzf gcc-5.5.0.tar.gz
cd gcc-5.5.0
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-4.3.2.tar.bz2
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-2.4.2.tar.bz2
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-0.8.1.tar.gz
wget ftp://gcc.gnu.org/pub/gcc/infrastructure/isl-0.14.tar.bz2
tar -xvjf gmp-4.3.2.tar.bz2
mv gmp-4.3.2 gmp
tar -xvjf mpfr-2.4.2.tar.bz2
mv mpfr-2.4.2 mpfr
tar -xvzf mpc-0.8.1.tar.gz
mv mpc-0.8.1 mpc
tar -xvjf isl-0.14.tar.bz2
mv isl-0.14 isl
# 创建构建目录,配置,构建和安装
cd ../
mkdir gcc-5.5.0-build
cd gcc-5.5.0-build
../gcc-5.5.0/configure --perfix=/opt/gcc-5.5.0 \
--enable-languages=c,c++ \
--disable-multilib \
--enable-shared \
--build=x86_64-centos-linux \
--enable-checking=release
gmake
gmake install
# 安装后配置
export LIBPATH=/opt/gcc-5.5.0/lib64
export LD_LIBRARY_PATH=$LIBPATH:$LD_LIBRARY_PATH
export PATH=/opt/gcc-5.5.0/bin:$PATH