[Patrick.Pelissier@loria.fr: [kalinabears@iinet.net.au: MPFR basics]]

Paul Zimmermann Paul.Zimmermann at loria.fr
Mon Dec 15 17:05:03 CET 2003


   Date: Mon, 15 Dec 2003 05:05:25 +1100
   From: Sisyphus <kalinabears at iinet.net.au>
   To: gmp <gmp-discuss at swox.com>
   Subject: MPFR basics

   Hi,
   The following builds and runs fine so long as I link to both -lmpfr and 
   - -lgmp (in that order):

   - -----------------------
   #include <stdio.h>
   #include <gmp.h>
   #include <mpfr.h>

   int main() {
	mpfr_t x;
	mpfr_init (x);
   /*   mpfr_set_str(x, "123456.2", 10, GMP_RNDN); */
	mpfr_clear(x);
	printf("Done\n");
	return 0;
   }
   - -----------------------

   But as soon as I include the mpfr_set_str() call I get (multiple) 
   undefined references to __gmpn_copyd and __gmpn_copyi.
   What have I done wrong ? I built gmp-4.1.2 and mpfr (in an MSYS shell on 
   Windows2000 using gcc) with:
   ./configure --disable-static --enable-shared --enable-mpfr

   Cheers,
   Rob

Are you sure you gave the correct -L option? I did on a Linux box:

$ tar zxf gmp-4.1.2.tar.gz
$ cd gmp-4.1.2
$ ./configure --disable-static --enable-shared --enable-mpfr
$ make
$ gcc -Impfr -I. -Lmpfr -L.libs e.c -lmpfr -lgmp
  # e.c is the above, with mpfr_set_str
$ ./a.out
Done

Regards,
Paul


More information about the gmp-discuss mailing list