GNU GCC 获取GCC源码
编译安装过程较长,防止ssh连接中断建议使用screen
解压GCC
tar -xvf gcc-9.2.0.tar.gz
执行configure报错
configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
their locations. Source code for these libraries can be found at
their respective hosting sites as well as at
ftp://gcc.gnu.org/pub/gcc/infrastructure/. See also
http://gcc.gnu.org/install/prerequisites.html for additional info. If
you obtained GMP, MPFR and/or MPC from a vendor distribution package,
make sure that you have installed both the libraries and the header
files. They may be located in separate packages.
Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.
需要安装GMP MPFR MPCMPC : ftp://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz
GMP : ftp://ftp.gnu.org/gnu/gmp/gmp-6.1.2.tar.xz
MPFR : http://ftp.gnu.org/gnu/mpfr/mpfr-4.0.2.tar.gz
这里提供了几个最新版本的下载地址
编译安装GMP创建一个临时目录temp并在temp下进行编译和安装
$tar -xvf gmp-6.1.2.tar.xz
$mkdir temp
$cd temp
$sudo ../gmp-6.1.2/configure --prefix=/usr/local/gmp-6.1.2
configure: summary of build options:
Version: GNU MP 6.1.2
Host type: haswell-pc-linux-gnu
ABI: 64
Install prefix: /usr/local/gmp-6.1.2
Compiler: gcc -std=gnu99
Static libraries: yes
Shared libraries: yes
$sudo make
$sudo make install
编译安装MPFRtar -xvf mpfr-4.0.2.tar.gz
cd mpfr-4.0.2.tar.gz
mkdir temp
cd temp
sudo ../configure --prefix=/usr/local/mpfr-4.0.2 --with-gmp=/usr/local/gmp-6.1.2
sudo make
sudo make check
sudo make install
指定gmp版本路径
--with-gmp=/user/gmp-6.1.0/gmp-6.1.0-obj
安装MPCtar -zxvf mpc-1.1.0.tar.gz
cd mpc-1.1.0/
mkdir temp
cd temp
sudo ../configure --prefix=/usr/local/mpc-1.1.0 --with-gmp=/usr/local/gmp-6.1.2 --with-mpfr=/usr/local/mpfr-4.0.2
sudo make
sudo make check
sudo make install
添加ld.so.confsudo vim /etc/ld.so.conf
添加
/usr/local/gmp-6.1.2/lib
/usr/local/mpfr-4.0.2/lib
/usr/local/mpc-1.1.0/lib
添加完成后保存执行
sudo ldconfig
安装GCC由于之前解压过GCC,如果没有解压可以执行tar
tar -xvf gcc-9.2.0.tar.gz
更改参数
sudo ../configure --prefix=/usr/local/gcc-9.2.0 --enable-threads=posix --disable-checking --enable--long-long --with-gmp=/usr/local/gmp-6.1.2 --with-mpfr=/usr/local/mpfr-4.0.2 --with-mpc=/usr/local/mpc-1.1.0 --with-isl=/usr/local/isl-0.18 --disable-multilib
终于创建makefile了