Building GCC requires GMP 4.2+, MPFR 2.3.1+ and MPC 0.8.0+
Asked Answered
P

6

113

I downloaded GCC 4.5 from http://www.netgull.com/gcc/releases/gcc-4.5.0/ but when I try to setup / build I am getting below error:

Linux:>~/shared_scripts/bin/gcc/gcc-4.5.0 1040> /x/home/prakash_satya/shared_scripts/bin/gcc/gcc-4.5.0/configure CC="gcc -m64" --prefix=/x/home/prakash_satya/shared_scripts/bin/gcc/gcc-4.5.0 --with-gmp-lib=/usr/lib64 --with-mpfr-lib=/usr/lib64 --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-languages=c,c++
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-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... /bin/sed
checking for gawk... gawk
checking for gcc... gcc -m64
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -m64 accepts -g... yes
checking for gcc -m64 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 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 2.3.1+ 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.
Linux:>~/shared_scripts/bin/gcc/gcc-4.5.0 1041>

The following libs are present in respective directories

/usr/lib/libgmp.a
/usr/lib64/libgmp.a

/usr/lib/libmpfr.a
/usr/lib64/libmpfr.a

I do not have libmpc.a library installed anywhere in boxes.

Based upon the error how can I know :

a) what is the current version of libgmp.a and libmpfr.a are installed.

b) If they are of incorrect version how can I deploy my own version without disturbing the current one?

Panicstricken answered 12/2, 2012 at 23:24 Comment(4)
try running ./contrib/download_prerequisites.sh from the gcc source dir. It worked for me (for the current version of gcc though (gcc-4.7)Bogy
The script no longer seems to have an .sh extension: ./contrib/download_prerequisites.Diderot
download_prerequisites.sh was added in 4.6 it looks like. 4.5.0 doesn't have it.Panther
./contrib/download_prerequisites works for gcc-4.8.5 as well. Thanks.Euhemerize
H
12

In the directory where I have those libraries installed (/usr/gnu64/lib), I also have a libgmp.la file (and libmpc.la and libmpfr.la files), which contain readable text. The SO version information is in there, but that is not quite the same as the 'product version'. It tells about link compatibility instead.

I was trying to investigate which version I had, and the weird solution I came up with was to run the GCC (4.6.1) that I built with the -v option. In part, it said:

GNU C (GCC) version 4.6.1 (x86_64-apple-darwin11.1.0)
    compiled by GNU C version 4.6.1, GMP version 5.0.1, MPFR version 3.0.0, MPC version 0.8.2
warning: GMP header version 5.0.1 differs from library version 5.0.2.
warning: MPFR header version 3.0.0 differs from library version 3.1.0.
warning: MPC header version 0.8.2 differs from library version 0.9.

So, it appears that I have GMP 5.0.2 installed (but I built GCC with 5.0.1), and MPFR 3.1.0 (but I built GCC with 3.0.0) and MPC 0.9 (but I built GCC with 0.8.2). The mismatch comes about because I tried to compile and install GCC 4.6.2 and it presumably needed the newer versions. (I didn't succeed, but that's a different story.)

I install my custom-built libraries in /usr/gnu64/lib, and then tell GCC that's where to find them with the configure options --with-mpfr=/usr/gnu64/lib, --with-gmp=/usr/gnu64/lib, --with-mpc=/usr/gnu/64/lib. These paths are hard-wired into GCC and it works from there.

Hackneyed answered 12/2, 2012 at 23:58 Comment(3)
I tried the same step but copying .a and .la to a local folder using --with-gmp/mpfr to local folder but it stills give the same error. Also I downloaded and build gmp/mpfr/mpc from gcc.gnu.org/pub/gcc/infrastructure [gmp-4.3.2.tar.bz2,mpfr-2.4.2.tar.bz2,mpc-0.8.1.tar.gz] but building mpc states - configure: error: GMP version >= 4.2 required while gcc still staes the same error.Panicstricken
@Prakash: in that case, assume GCC and its configuration suite knows what it is doing, and get on with compiling and installing the other three libraries. I've always done it as a separate operation, without reference to GCC (even though GCC triggered the rebuilds). I believe there may be a way to get GCC to build and install the libraries as it goes - by having the source for GMP, MPFR, MPC in the GCC source tree. Check the ./configure --help output for information.Hackneyed
Since writing this, I've taken to having GCC build the version of GMP, MPFR and MPC along with the compiler. I now get the source for the current version of the library, and extract it into the top-level directory of the GCC source: gmp-6.0.0, mpfr-3.1.2, etc. Then I create a symlink for each of them: ln -s gmp-6.0.0 gmp; ln -s mpfr-3.1.2 mpfr; ln -s mpc-1.0.2 mpc. Then I run GCC configure and build, and GCC builds these libraries too.Hackneyed
P
271

Inside the gcc directory, do this command:

./contrib/download_prerequisites

After that script, GMP, MPFR, and MPC will be ready to use. Continue with ./configure.

Prepositive answered 19/7, 2016 at 13:56 Comment(6)
Was trying to install gcc 6.2 on bash on ubuntu on windows, this command worked for me. Thanks!Selfcontent
Thanks for that. I was stuck on a machine with no sudo, and this solved my woesIronlike
One thing to mention: this command must be run in the gcc source root folder, it will download the files under there, if run it in other place, configure still cannot find the correct files.Privy
Thanks. It worked for me even on really old CentOS 4 when I wanted to compile newer GCC there.Seismology
Works for me! (on centos)Kimberleykimberli
Works for gcc-4.8.5 as well.Euhemerize
R
77

I had the same problem trying to install/compile GCC 4.8.1. Here is how I solved:

In Debian, just run this two commands:

apt-get install libmpc-dev
./configure
Rok answered 17/6, 2013 at 16:41 Comment(4)
On Amazon Linux, it's sudo yum install libmpc-develSheep
Centos also needs sudo yum install libmpc-develImpaste
On ubuntu 16 it is sudo apt-get install libmpc-devBitterweed
On Raspbian 9.13 there isn't such thing as libmpc-devFrechette
B
25

I had the same problem compiling GCC 4.9 branch.

For Red Hat and Fedora based systems, run the following command:

sudo yum install gmp gmp-devel mpfr mpfr-devel libmpc libmpc-devel

This will install the GNU multiple-precision (MP) libraries for integer, floating point, and complex numbers.

Baerl answered 14/11, 2014 at 4:55 Comment(0)
H
12

In the directory where I have those libraries installed (/usr/gnu64/lib), I also have a libgmp.la file (and libmpc.la and libmpfr.la files), which contain readable text. The SO version information is in there, but that is not quite the same as the 'product version'. It tells about link compatibility instead.

I was trying to investigate which version I had, and the weird solution I came up with was to run the GCC (4.6.1) that I built with the -v option. In part, it said:

GNU C (GCC) version 4.6.1 (x86_64-apple-darwin11.1.0)
    compiled by GNU C version 4.6.1, GMP version 5.0.1, MPFR version 3.0.0, MPC version 0.8.2
warning: GMP header version 5.0.1 differs from library version 5.0.2.
warning: MPFR header version 3.0.0 differs from library version 3.1.0.
warning: MPC header version 0.8.2 differs from library version 0.9.

So, it appears that I have GMP 5.0.2 installed (but I built GCC with 5.0.1), and MPFR 3.1.0 (but I built GCC with 3.0.0) and MPC 0.9 (but I built GCC with 0.8.2). The mismatch comes about because I tried to compile and install GCC 4.6.2 and it presumably needed the newer versions. (I didn't succeed, but that's a different story.)

I install my custom-built libraries in /usr/gnu64/lib, and then tell GCC that's where to find them with the configure options --with-mpfr=/usr/gnu64/lib, --with-gmp=/usr/gnu64/lib, --with-mpc=/usr/gnu/64/lib. These paths are hard-wired into GCC and it works from there.

Hackneyed answered 12/2, 2012 at 23:58 Comment(3)
I tried the same step but copying .a and .la to a local folder using --with-gmp/mpfr to local folder but it stills give the same error. Also I downloaded and build gmp/mpfr/mpc from gcc.gnu.org/pub/gcc/infrastructure [gmp-4.3.2.tar.bz2,mpfr-2.4.2.tar.bz2,mpc-0.8.1.tar.gz] but building mpc states - configure: error: GMP version >= 4.2 required while gcc still staes the same error.Panicstricken
@Prakash: in that case, assume GCC and its configuration suite knows what it is doing, and get on with compiling and installing the other three libraries. I've always done it as a separate operation, without reference to GCC (even though GCC triggered the rebuilds). I believe there may be a way to get GCC to build and install the libraries as it goes - by having the source for GMP, MPFR, MPC in the GCC source tree. Check the ./configure --help output for information.Hackneyed
Since writing this, I've taken to having GCC build the version of GMP, MPFR and MPC along with the compiler. I now get the source for the current version of the library, and extract it into the top-level directory of the GCC source: gmp-6.0.0, mpfr-3.1.2, etc. Then I create a symlink for each of them: ln -s gmp-6.0.0 gmp; ln -s mpfr-3.1.2 mpfr; ln -s mpc-1.0.2 mpc. Then I run GCC configure and build, and GCC builds these libraries too.Hackneyed
B
1

Centos7: sudo yum install libmpc-devel

Bedazzle answered 29/10, 2019 at 2:18 Comment(1)
Good on you for providing an answer . FYI rather than just give an answer It would be helpful to others to tell why you would want to run that command and what it should do. It is also a good idea to ensure that you answer all of the question that is askedPerrone
H
0

I've changed the base_url in contrib/download_prerequisites to base_url='gcc.gnu.org/pub/gcc/infrastructure/'. Then just follow the steps from the gcc website. This worked beautifully. Hope this helpes.

Hickory answered 27/4, 2022 at 14:54 Comment(2)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Obedience
The other comment answers this question much better. Your answer should be deleted. https://mcmap.net/q/193302/-building-gcc-requires-gmp-4-2-mpfr-2-3-1-and-mpc-0-8-0Heigho

© 2022 - 2024 — McMap. All rights reserved.