Error:Building GCC requires GMP 4.2+, MPFR 3.1.0+ and MPC 0.8.0+

参考链接:
https://blog.csdn.net/enson16855/article/details/52205044


在编译高版本gcc,执行下面配置命令时,

../configure --prefix=/usr/local/gcc-10.2.0/ --enable-checking=release --enable-languages=c,c++ --disable-multilib

报错如下:

adams@adams-pc:~/tmp/gcc/gcc-10.2.0/build$ ../configure --prefix=/usr/local/gcc-10.2.0/ --enable-checking=release --enable-languages=c,c++ --disable-multilib
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether ln works... yes
checking whether ln -s works... yes
checking for a sed that does not truncate output... /usr/bin/sed
checking for gawk... gawk
checking for libatomic support... yes
checking for libitm support... yes
checking for libsanitizer support... yes
checking for libvtv support... yes
checking for libhsail-rt support... yes
checking for libphobos support... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking whether g++ accepts -static-libstdc++ -static-libgcc... yes
checking for gnatbind... no
checking for gnatmake... no
checking whether compiler driver understands Ada... no
checking how to compare bootstrapped objects... cmp --ignore-initial=16 $$f1 $$f2
checking for objdir... .libs
checking for the correct version of gmp.h... yes
checking for the correct version of mpfr.h... yes
checking for the correct version of mpc.h... no
configure: error: Building GCC requires GMP 4.2+, MPFR 3.1.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
https://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.
adams@adams-pc:~/tmp/gcc/gcc-10.2.0/build$ 

根据报错信息可以知道,是GMP,MPFR和MPC版本太低导致的上述问题。

所以需要编译出高版本,然后在编译gcc时指定路径,使其在编译时可以找到高版本的库以及头文件。


GMP编译

下载地址:
ftp://ftp.gnu.org/gnu/gmp/

我们选择gmp-5.0.1.tar.bz2版本进行下载。

wget ftp://ftp.gnu.org/gnu/gmp/gmp-5.0.1.tar.bz2
tar -vxf gmp-5.0.1.tar.bz2
cd gmp-5.0.1/
./configure --prefix=/usr/local/gmp-5.0.1
make
sudo make install

MPFR编译

下载地址:
https://ftp.gnu.org/gnu/mpfr/

我们选择mpfr-3.1.5.tar.xz版本进行下载。

wget https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.5.tar.xz
tar -vxf mpfr-3.1.5.tar.gz
cd mpfr-3.1.5/
./configure --prefix=/usr/local/mpfr-3.1.5 --with-gmp=/usr/local/gmp-5.0.1
make
sudo make install

MPC编译

下载地址:
http://www.multiprecision.org/mpc/download.html

我们选择mpc-0.9.tar.gz版本进行下载。

wget http://www.multiprecision.org/downloads/mpc-0.9.tar.gz
tar -vxf mpc-0.9.tar.gz
cd mpc-0.9/
./configure --prefix=/usr/local/mpc-0.9 --with-gmp=/usr/local/gmp-5.0.1 --with-mpfr=/usr/local/mpfr-3.1.5
make
sudo make install

GCC 配置

../configure --prefix=/usr/local/gcc-10.2.0/ --enable-checking=release --enable-languages=c,c++ --disable-multilib --with-gmp=/usr/local/gmp-5.0.1 --with-mpfr=/usr/local/mpfr-3.1.5 --with-mpc=/usr/local/mpc-0.9

这次就可以配置成功了!


CSDN下载:

gmp-5.0.1.tar.bz2

mpc-0.9.tar.gz

mpfr-3.1.5.tar.xz

没有积分的话,可以给我留言。


你可能感兴趣的:(Linux)