14

I'm installing gcc 4.5.2 with mpc 0.8.2, mpfr 3.1.0, and gmp 5.0.2. I've copied each of the mpc, mpfr, and gmp directories into the gcc-4.5.2 directory (removing the version tags). GCC successfully configures. When I run make, however, I get:

checking for MPFR... no
configure: error: libmpfr not found or uses a different ABI.
make[1]: *** [configure-mpc] Error 1
make[1]: leaving directory cross/build/gcc
make: *** [all] Error 2

MPFR is located in cross/src/gcc-4.5.2/mpfr. MPFR already was built successfully. Anyone know why mpc is unable to configure?

I think the problem may partially have to do with the libs/headers for MPFR being in cross/src/gcc-4.5.2/mpfr/src and not in cross/src/gcc-4.5.2/mpfr. All I did was extract and copy though- this is the default directory structure.

joelparkerhenderson
  • 34,808
  • 19
  • 98
  • 119
Robert Mason
  • 3,949
  • 3
  • 31
  • 44

6 Answers6

29

I was having the same issue. But it seems this happens because latest version of MPFR (in your case 3.1.0) changed the directory hierarchy.

Instead, before configuring, run the following when you are inside gcc's source directory (may only work for gcc4.5.2 or later):

./contrib/download_prerequisites

It will download the necessary MPFR, GMP and MPC versions (but probably not the latest versions) and unpack those for gcc installation.

After that, you can continue with your configure, make and make install.

Hope this helps.

-Rakib

Rakib
  • 791
  • 8
  • 19
  • 1
    Awesome answer. This works great. I did not know that the libs could be downloaded automatically. –  May 20 '13 at 17:28
  • 1
    If you're on a Mac replace the "wget" commands in the script with "curl -OL" – gerardw Mar 25 '15 at 17:06
  • 1
    great answer, however found no download_prerequisites script in gcc 4.4, so did it manually – Denis Jun 23 '15 at 14:56
  • @Denis Nice catch. Never tried to install gcc4.4 manually. Updated my answer. Thanks. How did you know which versions to download? – Rakib Jun 23 '15 at 15:23
  • @rakib the configure script lists them as errors, when no gmp nor mpfr are found – Denis Jun 23 '15 at 17:58
9

I found that if I ran export C_INCLUDE_PATH=/cross/gcc-4.5.2/mpfr/src then export LD_LIBRARY_PATH=/cross/build-gcc-4.5.2/mpfr/src/.libs and finally export LIBRARY_PATH=$LD_LIBRARY_PATH everything worked as expected.

The nagging question is why gcc's own configure scripts set the flags wrong. It should know that mpfr's libs are not in mpfr/.libs but in mpfr/src/.libs, however it passes the former to mpc/configure.

Robert Mason
  • 3,949
  • 3
  • 31
  • 44
  • I had (and am having) the same problem with building gcc on Windows with MinGW/msys. Exporting/setting these variables as suggested didn't help in my case. Is the correct time and order of setting them important, or is there anything else I could check? – René Nyffenegger Mar 23 '12 at 22:26
  • I don't know if LD_LIBRARY_PATH/LIBRARY_PATH/C_INCLUDE_PATH are checked on windows. You could try editing the makefile and adding in the -I and -L options to CFLAGS in there. – Robert Mason Mar 24 '12 at 00:50
  • 2
    This changed with MPFR 3.1 (the header location) which is why GCC uses the old version. THe newer version isn't strictly supported, the [GCC infrastructure downloads page](http://mirrors-us.seosue.com/gcc/infrastructure/) still has version 2.4.2 listed. – rubenvb Apr 26 '12 at 19:15
  • Thanks, that explains it @rubenvb. Though I'm surprised that they don't have some sort of autotools hack to get it to recognize the directory layout for MPFR 3.1. Seems like they're compatible with every version of every program written since the 90s, or else what are those *gigantic* configure scripts for :P – Robert Mason Apr 27 '12 at 17:55
3

Try this while configuring:

./configure --prefix=<DIR YOU WANT TO INSTALL GCC> \
--with-gmp=<DIRECTORY YOU INSTALLED GMP> \
--with-mpc=<MPC DIR> --with-mpfr=<MPFR DIR>
Tisho
  • 8,320
  • 6
  • 44
  • 52
Amit Nag
  • 31
  • 1
3

I've had the same problem for a few hours, but I solved it in another other way.

I've deleted all old folders like gcc-4.* and gcc-build, because there was an old configuration inside. After that, I checked out again with version-check.sh if everything was in the right location.

I used Debian and it was missing bison and gnu awk! Why whatever. I installed the two again and started with installing gcc. Now everything is OK.

Perhapse you have a similar problam which can be solved in the same manner. I have to check every time when I start vbox and maybe it is a problem with my vbox-image, so when I start vbox I run a versions-check.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
3

No need you can try like this:

./configure \
--with-gmp=/opt/install/local\
--with-mpfr=/opt/install/local \
--with-mpc=/opt/install/local \
--with-gmp-include=/opt/install/build/gmp-6.0.0 \
--with-mpfr-include=/opt/install/build/mpfr-3.1.2/src \
--with-mpc-include=/opt/install/build/mpc-1.0.2/src --enable-languages=c,c++
yet
  • 773
  • 11
  • 19
2

instead of --with-mpfr=, I used --with-mpfr-lib=your-mprf-dir/lib(64?) --with-mpfr-include=your-mprf-dir/include.

This works for me. PS: mprf-3.1.0 gmp-5.0.2 mpc-0.9

a'Q
  • 455
  • 4
  • 3