Simple MPFR program

Jeffrey Green etruscan at email.arc.nasa.gov
Fri Jun 18 00:55:12 CEST 2004


I can not get any program with any mpfr anything to compile.  I am not a
particularly experienced c++ programmer, so I'm sorry if this is extremely
basic.  I have tried the following options, with c++ and c as well, with
no success to get a simple program compiling.  If anyone can help me out,
I would appreciate it.
Using gcc 3.3.2 and 2.96, error messages were virtually identical, these
are the 3.3.2 errors.

Thanks much.

C++ program:
#include <iostream>
#include "gmp.h"
#include "mpfr.h"

using namespace std;
int main(int argc, char *argv[]) {
  cout << "Hello World!\n";
  mpfr_t s;
  mpfr_init(s);
  mpfr_set_d(s,10.0,GMP_RNDN);
  return 0;
}

compile attempt:  g++ -I/usr/local/gmp-4.1.3/include
-L/usr/local/gmp-4.1.3/lib/ -lgmp -lmpfr -o grumble grumble.cpp

Error:
/tmp/ccj8Il7L.o: In function `main':
/tmp/ccj8Il7L.o(.text+0x2b): undefined reference to `mpfr_init'
/tmp/ccj8Il7L.o(.text+0x48): undefined reference to `mpfr_set_d'
collect2: ld returned 1 exit status

c++ program 2:

#include <iostream>
#include "gmp.h"
#include "mpfr.h"

#include <iostream>
#include "gmp.h"
#include "mpfr.h"

int main(int argc, char *argv[]) {
  mpfr_t s;
  mpfr_init(s);
  mpfr_set_d(s,10.0,GMP_RNDN);
  return 0;
}

compile attempt:  g++ -I/usr/local/gmp-4.1.3/include
-L/usr/local/gmp-4.1.3/lib/ -lgmp -lmpfr -o grumble grumble.cpp

Error:
/tmp/ccj8Il7L.o: In function `main':
/tmp/ccj8Il7L.o(.text+0x2b): undefined reference to `mpfr_init'
/tmp/ccj8Il7L.o(.text+0x48): undefined reference to `mpfr_set_d'
collect2: ld returned 1 exit status

C program:
#include "gmp.h"
#include "mpfr.h"

int main(int argc, char *argv[]) {
  mpfr_t s;
  mpfr_init(s);
  mpfr_set_d(s,10.0,GMP_RNDN);
  return 0;
}

compile attempt:  gcc -I/usr/local/gmp-4.1.3/include/
-L/usr/local/gmp-4.1.3/lib/ -lgmp -lmpfr grumble.c

Error:
/tmp/cc2uHhjk.o: In function `main':
/tmp/cc2uHhjk.o(.text+0x17): undefined reference to `mpfr_init'
/tmp/cc2uHhjk.o(.text+0x34): undefined reference to `mpfr_set_d'
collect2: ld returned 1 exit status

compile attempt: gcc -I/usr/local/gmp-4.1.3/include -o grumble grumble.c
-static /usr/local/gmp-4.1.3/lib/libgmp.a 
/usr/local/gmp-4.1.3/lib/libmpfr.a 


Error:
/usr/local/gmp-4.1.3/lib/libmpfr.a(set_d.o): In function
`mpfr_set_d':
/usr/src/gmp-4.1.3/mpfr/set_d.c:216: undefined reference to
`__gmpn_lshift'
/usr/src/gmp-4.1.3/mpfr/set_d.c:218: undefined reference to `__gmpn_copyi'
/usr/local/gmp-4.1.3/lib/libmpfr.a(set_dfl_prec.o): In function
`mpfr_set_default_prec':
/usr/src/gmp-4.1.3/mpfr/set_dfl_prec.c:33: undefined reference to
`__gmp_assert_fail'
/usr/local/gmp-4.1.3/lib/libmpfr.a(init2.o): In function `mpfr_init2':
/usr/src/gmp-4.1.3/mpfr/init2.c:35: undefined reference to
`__gmp_assert_fail'
/usr/src/gmp-4.1.3/mpfr/init2.c:40: undefined reference to
`__gmp_allocate_func'
/usr/local/gmp-4.1.3/lib/libmpfr.a(round_prec.o): In function
`mpfr_round_raw_generic':
/usr/src/gmp-4.1.3/mpfr/round_prec.c:79: undefined reference to
`__gmp_assert_fail'
/usr/src/gmp-4.1.3/mpfr/round_prec.c:84: undefined reference to
`__gmp_assert_fail'
/usr/src/gmp-4.1.3/mpfr/round_prec.c:89: undefined reference to
`__gmpn_copyd'
/usr/src/gmp-4.1.3/mpfr/round_prec.c:107: undefined reference to
`__gmp_assert_fail'
/usr/src/gmp-4.1.3/mpfr/round_prec.c:148: undefined reference to
`__gmpn_copyi'
/usr/local/gmp-4.1.3/lib/libmpfr.a(round_prec.o): In function
`mpfr_round_prec':
/usr/src/gmp-4.1.3/mpfr/round_prec.c:164: undefined reference to
`__gmp_assert_fail'
/usr/src/gmp-4.1.3/mpfr/round_prec.c:171: undefined reference to
`__gmp_reallocate_func'
/usr/src/gmp-4.1.3/mpfr/round_prec.c:207: undefined reference to
`__gmpn_copyi'
/usr/local/gmp-4.1.3/lib/libmpfr.a(round_prec.o): In function
`mpfr_can_round_raw':
/usr/src/gmp-4.1.3/mpfr/round_prec.c:289: undefined reference to
`__gmpn_copyi'
collect2: ld returned 1 exit status


compile

-jeff
415.516.4793




More information about the gmp-discuss mailing list