1、下载gcc9.3.0源码包
wget https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-9.3.0/gcc-9.3.0.tar.gz
sudo tar xvf gcc-9.3.0.tar.gz
./contrib/download_prerequisites #运行自带脚本下载4个依赖
如果下载速度慢或下载不了,可去https://mirrors.tuna.tsinghua.edu.cn/gnu 下查找相应安装包,在download_prerequisites脚本中有相当依赖版本,自行查找
2、安装四个依赖包
2.1gmp编译安装
tar xf gmp-6.1.0.tar
cd gmp-6.1.0
./configure --prefix=/usr/local/gmp-6.1.0
make
make install
2.2、mpfr编译安装
tar xzf mpfr-3.1.4.tar.gz
cd mpfr-3.1.4
./configure --prefix=/usr/local/mpfr-3.1.4 --with-gmp=/usr/local/gmp-6.1.0
make
make install
2.3、安装mpc
tar xzf mpc-1.0.3.tar.gz
cd mpc-1.0.3
./configure --prefix=/usr/local/mpc-1.0.3 --with-gmp=/usr/local/gmp-6.1.0 --with-mpfr=/usr/local/mpfr-3.1.4
make
make install
2.4、安装isl
tar xzf isl-0.18.tar.gz
cd isl-0.18
./configure --prefix=/usr/local/isl-0.18 --with-gmp=/usr/local/gmp-6.1.0 --with-mpfr=/usr/local/mpfr-3.1.4
--with-mpc=/usr/local/mpc-1.0.3
make
make install
3、编译GCC9.3.0
3.1 环境变量先搞上
export LD_LIBRARY_PATH=/usr/local/gmp-6.1.0/lib:/usr/local/mpfr-3.1.4/lib:/usr/local/mpc-1.0.3/lib:/usr/local/isl-0.18/lib:$LD_LIBRARY_PATH
可以写在.bashrc文件中
3.2 mkdir build && cd build
../configure --prefile=/usr/local/gcc-9.3.0--enable-checking=release --enable-languages=c,c++ --disable-multilib
make && make install
时间较长2个小时左右,编译安装完成后,将原有gcc 版本替换,可以直接删除原有gcc,用/usr/local/gcc-9.3.0/bin/gcc 直接覆盖,也可以保留原有更名
标签:gcc,tar,centos,--,编译,gcc9.3,gmp,local,usr From: https://www.cnblogs.com/dinmin/p/17253735.html