gmp issues

After a herculean struggle I managed to get gmp working on windows.

But... I can't get the gmpxx library to work.

My code is:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>

#include <stdio.h>

#include <gmp.h>
#include <gmpxx.h>

using namespace std;



int main()

{

    mpf_set_default_prec(100000);

    mpf_t a;
    mpf_init (a);
    mpf_set_ui (a,1);

    cout <<a;
	
}


which gives me:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
g++ gmp_test.cpp  -lgmp -lcygwin -lgmpxx

c:/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libgmpxx.a(osmpf.o):osmpf.cc:(.te
xt+0x40): undefined reference to `__gxx_personality_sj0'
c:/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libgmpxx.a(osmpf.o):osmpf.cc:(.te
xt+0x5c): undefined reference to `_Unwind_SjLj_Register'
c:/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libgmpxx.a(osmpf.o):osmpf.cc:(.te
xt+0x189): undefined reference to `__gmp_doprnt_mpf2'
c:/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libgmpxx.a(osmpf.o):osmpf.cc:(.te
xt+0x198): undefined reference to `__gmp_asprintf_final'
c:/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libgmpxx.a(osmpf.o):osmpf.cc:(.te
xt+0x1fb): undefined reference to `_Unwind_SjLj_Unregister'
c:/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libgmpxx.a(osmpf.o):osmpf.cc:(.te
xt+0x276): undefined reference to `_Unwind_SjLj_Resume'
c:/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libgmpxx.a(osfuns.o):osfuns.cc:(.
rdata+0x4): undefined reference to `__gmp_asprintf_memory'
c:/mingw/bin/../lib/gcc/mingw32/4.4.0/../../../libgmpxx.a(osfuns.o):osfuns.cc:(.
rdata+0x8): undefined reference to `__gmp_asprintf_reps'
collect2: ld returned 1 exit status


Any help much appreciated.

Taking out the "cout" line makes it compile fine.
Last edited on
It looks like you missed an I/O gmp library. I've not used gmp, so I don't know the name, but it's definitely a link error.
Topic archived. No new replies allowed.