views:

441

answers:

1

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?

+1  A: 

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)
Jonathan Leffler
I used `CC=gcc -m64'` and it worked
None