configure: error: Building GCC requires GMP 4.2+, MPFR 3.1.0+ and MPC 0.8.0+.

8 篇文章 0 订阅

实验环境:
OS: Ubuntu 20.10LTS
GCC: gcc 10.3.0
Riscv-gcc: gcc 10.2.0


编译GCC报错

在编译riscv-gcc交叉编译工具链时报如下错误。

imaginemiracle:riscv-gcc-10.2.0$ ./configure --prefix=/home/imaginemiracle/Disk_D/Linux_Workspace/riscv-project/riscv-gcc/riscv64-linux-gcc-10.2.0-install/ --with-arch=rv64imafdc --with-abi=lp64d --enable-linux
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... no
checking for mawk... mawk
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... 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.

从错误信息中可以看到,构建该版本的gcc需要:
4.2版本以上的GMP;
3.1.0版本以上的MPFR;
0.8.0版本以上的MPC

安装GMP

GMP官网下载地址: https://ftp.gnu.org/gnu/gmp/
CSDN下载: gmp-6.2.0 (注: 网络不好的朋友可以选择这里下载,若无法下载请留言)
这里笔者选择的版本为gmp 6.2.0

imaginemiracle:~$ wget ftp://ftp.gnu.org/gnu/gmp/gmp-6.2.0.tar.bz2
imaginemiracle:~$ tar -xvf gmp-6.2.0.tar.bz2
imaginemiracle:~$ cd gmp-6.2.0/
imaginemiracle:gmp-6.2.0$ ./configure --prefix=/usr/local/gmp-6.2.0
imaginemiracle:gmp-6.2.0$ make
imaginemiracle:gmp-6.2.0$ sudo make install

安装MPFR

MPFR下载地址: https://ftp.gnu.org/gnu/mpfr/
CSDN下载: mpfr-4.1.0 (注: 网络不好的朋友可以选择这里下载)
这里笔者选择的版本为mpfr 4.1.0

imaginemiracle:~$ wget https://ftp.gnu.org/gnu/mpfr/mpfr-4.1.0.tar.gz
imaginemiracle:~$ tar -xvf mpfr-4.1.0.tar.gz
imaginemiracle:~$ cd mpfr-4.1.0/
imaginemiracle:mpfr-4.1.0$ ./configure --prefix=/usr/local/mpfr-4.1.0 --with-gmp=/usr/local/gmp-6.2.0
imaginemiracle:mpfr-4.1.0$ make
imaginemiracle:mpfr-4.1.0$ sudo make install

安装MPC

MPC官网下载地址: https://ftp.gnu.org/gnu/mpc/
CSDN下载: mpc-1.2.0 (注: 网络不好的朋友可以选择这里下载)
这里笔者选择的版本为MPC 1.2.0

imaginemiracle:~$ wget https://ftp.gnu.org/gnu/mpc/mpc-1.2.0.tar.gz
imaginemiracle:~$ tar -xvf mpc-1.2.0.tar.gz
imaginemiracle:~$ cd mpc-1.2.0/
imaginemiracle:~$ ./configure --prefix=/usr/local/mpc-1.2.0 --with-gmp=/usr/local/gmp-6.2.0 --with-mpfr=/usr/local/mpfr-4.1.0
imaginemiracle:~$ make
imaginemiracle:~$ sudo make install

这一步有可能会报错误

imaginemiracle:mpc-1.2.0$ ./configure --prefix=/usr/local/mpc-1.2.0 --with-gmp=/usr/local/gmp-6.2.0 --with-mpfr=/usr/local/mpfr-4.1.0
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for CC and CFLAGS in gmp.h... yes CC=gcc CFLAGS=-O2 -pedantic -m64 -mtune=k8 -march=k8
checking for CC=gcc and CFLAGS=-O2 -pedantic -m64 -mtune=k8 -march=k8... 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 whether gcc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of gcc... gcc3
checking for ar... ar
checking the archiver (ar) interface... ar
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /usr/bin/dd
checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1
checking for mt... mt
checking if mt is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for gmp.h... yes
checking for ANSI C header files... (cached) yes
checking locale.h usability... yes
checking locale.h presence... yes
checking for locale.h... yes
checking for inttypes.h... (cached) yes
checking for stdint.h... (cached) yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking for unistd.h... (cached) yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking sys/resource.h usability... yes
checking sys/resource.h presence... yes
checking for sys/resource.h... yes
checking whether time.h and sys/time.h may both be included... yes
checking complex.h usability... yes
checking complex.h presence... yes
checking for complex.h... yes
checking for library containing creal... -lm
checking whether creal, cimag and I can be used... yes
checking for an ANSI C-conforming const... yes
checking for size_t... yes
checking for gettimeofday... yes
checking for localeconv... yes
checking for setlocale... yes
checking for getrusage... yes
checking for dup... yes
checking for dup2... yes
checking for __gmpz_init in -lgmp... yes
checking for MPFR... no
configure: error: libmpfr not found or uses a different ABI (including static vs shared).

解决方案

imaginemiracle:mpc-1.2.0$ sudo apt-get install libmpfr-dev
imaginemiracle:mpc-1.2.0$ ./configure --prefix=/usr/local/mpc-1.2.0 --with-gmp=/usr/local/gmp-6.2.0 --with-mpfr=/usr/local/mpfr-4.1.0

再次编译GCC

分别指定GMPMPFRMPC路径,配置成功。

imaginemiracle:riscv-gcc-10.2.0$ ./configure --prefix=/home/imaginemiracle/Disk_D/Linux_Workspace/riscv-project/riscv-gcc/riscv64-linux-gcc-10.2.0-install/ --with-gmp=/usr/local/gmp-6.2.0 --with-mpfr=/usr/local/mpfr-4.1.0 --with-mpc=/usr/local/mpc-1.2.0 --with-arch=rv64imafdc --with-abi=lp64d --enable-linux --enable-multilib
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Imagine Miracle

爱你哟 =^ v ^=

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值