升级 gcc 出错排查

时间:2021-02-06 06:58:45
gcc 的安装过程大概是

1. 下载

2. 解压

3. 创建新目录, 进入创建新目录, 执行 解压后gcc 目录的 configure


这里,列出我遇到的升级过程过的错误消息,及我所使用的解决方法

1. 执行 ../gcc-5.3/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.

解决方法:

确认 gmp, mpfr, mpc 包已经安装,并且版本正确
# rpm -qa | grep gmp
# rpm -qa | grep mpfr
# rpm -qa | grep mpc

由于 mpc 在机器上没有安装,造成这个错误.下载 mpc 的 tar 包安装
下载地址: http://www.multiprecision.org/index.php?prog=mpc&page=download
这里选择 0.8.1 的安装.最新的包会依赖其它包.
安装过程大体(./configure && make && make install)

2. 解决问题1 后,继续执行 ../gcc-5.3/configure 出现如下错误消息

/usr/bin/ld: crt1.o: No such file: No such file or directory
collect2: ld returned 1 exit status
configure: error: I suspect your system does not have 32-bit developement libraries (libc and headers). If you have them, rerun configure with --enable-multilib. If you do not have them, and want to build a 64-bit-only compiler, rerun configure with --disable-multilib.

解决方法:

# ../gcc-5.3.0/configure --disable-multilib
使用选项 --disable-multilib

3. 继续执行 ../gcc-5.3/configure 又出现如下错误消息

configure: error: error verifying int64_t uses long long
make[2]: *** [configure-stage1-gcc] Error 1
make[2]: Leaving directory `/tmp/gcc_build'
make[1]: *** [stage1-bubble] Error 2
make[1]: Leaving directory `/tmp/gcc_build'
make: *** [all] Error 2

解决方法:

安装 gcc-c++ 包