GCC cant find GMP, MPFR and MPC libraries
Asked Answered
T

7

8

I am trying to cross-compile GCC on Mac OS 10.5.7. I used this command to configure GCC after installing GMP, MPFR, and MPC:

../gcc-4.5.0/configure --target=$i586-elf --prefix=/usr/local/cross \
    --disable-nls \
    --enable-languages=c,c++,fortran,java,objc,obj-c++,treelang,ada \
    --without-headers --with-libiconv-prefix=/opt/local --with-gmp=/usr/local \
    --with-mpfr=/usr/local --with-mpc=/usr/local

I got this error:

checking for the correct version of gmp.h... buggy but acceptable
checking for the correct version of mpfr.h... yes
checking for the correct version of mpc.h... yes
checking for the correct version of the gmp/mpfr/mpc libraries... 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.

Why could GCC find the headers for GMP, MPFR, and MPC but not the libraries?

Treasurehouse answered 18/8, 2010 at 2:20 Comment(1)
I had the same problem trying to build Linux From Scratch D:Benford
C
9

I suspect that the problem may be that the libraries are for 32-bit when you are attempting to build a 64-bit compiler, or vice versa.

I was able to build GCC 4.5.1 on MacOS X 10.6.4 recently, but I built and installed the GMP, MPFR and MPC libraries myself - in /usr/gnu64 (a non-standard location that I use for stuff that I install for my own benefit). I also used the configuration option:

CC='gcc -m64'

to force a 64-bit build. I had similar problems on Linux (plus a problem with a regex in opt-functions.awk - easily fixed with two back-slashes in front of an open brace) and found that there were updates to the MPFR and MPC libraries since I built on MacOS X:

  • GMP 5.0.1 (instead of 4.2.4)
  • MPC 0.8.2 (instead of 0.8.1)
  • MPFR 3.0.0 (instead of 2.4.2)

Since I wrote this, I've changed my methodology somewhat. What I now do is documented in Install GNU GCC on Mac. Basically, I get the current versions of GMP, MPC, MPFR and put their source code into the GCC source directory, and let GCC compile the libraries for itself. This makes GCC deal with locating the libraries.

Casarez answered 18/8, 2010 at 2:47 Comment(1)
Either of two places: CC="gcc -m64" ../gcc-4.5.1/configure ... or you can specify it as an argument: ../gcc-4.5.1/configure CC="gcc -m64" .... Both work; I usually use it as an environment variable (before the command). If you use a sea shell (tcsh, etc), use the argument form.Casarez
F
5

You should use

--with-gmp=/usr/local/include \
    --with-mpfr=/usr/local/include --with-mpc=/usr/local/include

instead of

--with-gmp=/usr/local \
    --with-mpfr=/usr/local --with-mpc=/usr/local
Forlorn answered 20/4, 2011 at 23:32 Comment(1)
This isn't correct. GCC's ./configure script states that --with-mpc=PATH is Equivalent to --with-mpc-include=PATH/include plus --with-mpc-lib=PATH/lib, and the same exact wording for --with-gmp and --with-mpfrPoliti
L
2

I had the same problem trying to compile gcc-4.6.0 on OX 10.6.6. I was using gmp-4.3.2 ; using instead gmp-5.0.1, the configure script appears to correctly guess "CC=gcc -std=gnu99 CFLAGS=-O2 -pedantic -m64 -mtune=core2 -march=core2", and passes that on to mpfr (3.0.1) and mpc (0.9) , so anyone using these or more recent versions shouldn't get this error.

Lianne answered 9/4, 2011 at 0:44 Comment(0)
H
1

I would suggest installing gmp, mpfr and mpc by downloading them from their websites. Then run ./configure (in the folder where the files downloaded) and sudo make install.

GCC should compile then on Mac OSX (mountain lion).

Note that mpc depends on mpfr and gmp.

I used this to compile pinion kernel on Mac OSX.

Hutson answered 9/8, 2012 at 12:16 Comment(0)
T
0

With mac ports mpfr, libmpc and gmp installed, I was able to tack this on the configure script:

--with-mpc=/opt/local/var/macports/software/libmpc/0.8.2_0/opt/local
--with-gmp=/opt/local/var/macports/software/gmp/5.0.1_0/opt/local
--with-mpfr=/opt/local/var/macports/software/mpfr/3.0.0-p8_0/opt/local 

This was to compile a ti msp430 toolchain.

Trichomonad answered 28/6, 2011 at 13:11 Comment(0)
L
0

I just solved a similar problem. Since my CPU is x86_64 but my OS is 32bit, when I install GMP(5.0.2), it attempt to configure in 64bit. So I recompiled my GMP with configuration like ABI=32 ./configure... then this GCC problem disappeared.

Lawful answered 17/10, 2011 at 13:55 Comment(0)
R
0

Had similar problem in Ubuntu 16.04 64 bit. Solved by using mpc-1.0.1.tar.gz, mpfr-3.1.6.tar.xz and gmp-6.1.2.tar.xz

Railway answered 27/9, 2017 at 18:25 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.