mini-gmp

paul zimmermann Paul.Zimmermann at inria.fr
Mon Jun 15 08:13:36 UTC 2015


       Dear Niels,

> From: nisse at lysator.liu.se (Niels Möller)
> Date: Mon, 15 Jun 2015 09:57:39 +0200
> 
> Zimmermann Paul <Paul.Zimmermann at inria.fr> writes:
> 
> > I tried to compile MPFR with mini-gmp. I needed to do a few changes:
> 
> Replying to an old mail. How did this work out? How do you deal with gmp
> vs mini-gmp in public mpfr header files and the mpfr ABI?
> 
> Regards,
> /Niels
> 
> -- 
> Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
> Internet email is subject to wholesale government surveillance.

as far as I remember, it worked at the end. See the doc/mini-gmp file in the
MPFR svn repo (reproduced below). This was with GMP 6.0.0. I did not test it
with more recent GMP snapshot. Maybe some changes in mini-gmp.c and mini-gmp.h
are no longer necessary. Cf MPFR_USE_MINI_GMP for your last question.

Best regards,
Paul

How to compile GNU MPFR with mini-gmp
=====================================

(this was tested with MPFR r9149 and GMP 6.0.0 on x86_64 GNU/Linux machine)

1) extract the GMP tarball in say /tmp/gmp-6.0.0
   go into /tmp/gmp-6.0.0/mini-gmp
   add the following line in mini-gmp.c (say at line 53):
   char gmp_version[] = "6.0.0";
   gcc -O2 -g -fPIC -c mini-gmp.c
   ar r libgmp.a mini-gmp.o

2) create a GMP install directory in say /tmp
   mkdir /tmp/include
   mkdir /tmp/lib
   cp libgmp.a /tmp/lib
   cp mini-gmp.h /tmp/include/gmp.h

3) do the following changes in /tmp/include/gmp.h:

$ diff gmp.h.orig gmp.h
29a30,35
> #define __GNU_MP_VERSION            5
> #define __GNU_MP_VERSION_MINOR      1
> #define __GNU_MP_VERSION_PATCHLEVEL 3
>
> extern char gmp_version[];
>
34a41,46
> #endif
>
> /* random generation functions */
> #ifndef gmp_randstate_t
> typedef long int __gmp_randstate_struct;
> typedef __gmp_randstate_struct gmp_randstate_t[1];

4) extract the MPFR tarball in say /tmp/mpfr-3.1.2
   ./configure --with-gmp=/tmp --enable-mini-gmp

Note: to use this version of the MPFR library, you need to define
the MPFR_USE_MINI_GMP macro before including mpfr.h (alternatively,
you can modify mpfr.h to define this macro at the beginning).



More information about the gmp-devel mailing list