how to start using GMP

Dongvu Tonien dongvu.tonien at
Tue Aug 1 09:00:53 CEST 2006


I know the question is silly- but I have scanned through Manual, but I
still don't know how to use GMP. Please help me.

I downloaded the GMP and had it on my Unix account


I went inside the directory gmp-4.2.1 and followed the install instructions:
./configure, make, make check, which run ok

Then I created a new directory $HOME/test and wrote a simple program:

#include "gmp.h"

int main (void){
  mpz_t integ;
  mpz_init_set_str (integ, "3141592653589793238462643383279502884", 10);
  return 0;

compile it:
g++ -lgmpxx -lgmp error: gmp.h: No such file or directory

So I changed  #include "gmp.h" to #include "../gmp-4.2.1/gmp.h"
compile it, but still error

g++ -lgmpxx -lgmp
ld: fatal: library -lgmpxx: not found
ld: fatal: library -lgmp: not found
ld: fatal: File processing errors. No output written to a.out
collect2: ld returned 1 exit status

Thank you for your time.

More information about the gmp-discuss mailing list