how to start using GMP

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


Hi,

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

$HOME/gmp-4.2.1

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: t.cc

#include "gmp.h"

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

compile it:
g++ t.cc -lgmpxx -lgmp
t.cc:1:17: 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++ t.cc -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.
--Dongvu


More information about the gmp-discuss mailing list