gmp 4.2.1, mingw problems

Marco Trudel mtrudel at gmx.ch
Thu Dec 28 14:14:40 CET 2006


Hello list

I'm working with the current gmp 4.2.1 release on Linux and Windows. I 
configure it with "--enable-static --disable-shared --enable-cxx" on 
both platforms.
On Linux, make and "make check" works and I can compile my application.
On Windows (mingw), make works but "make check" fails with:

creating libtests.la
(cd .libs && rm -f libtests.la && ln -s ../libtests.la libtests.la)
gcc -DHAVE_CONFIG_H -I. -I. -I.. -I..    -m32 -O2 -fomit-frame-pointer 
-mtune=pentiumpro -march=pentiumpro -mno-cygwin -c t-bswap.c
/bin/sh ../libtool --mode=link gcc  -m32 -O2 -fomit-frame-pointer 
-mtune=pentiumpro -march=pentiumpro -mno-cygwin   -o t-bswap.exe 
t-bswap.o libtests.la ../libgmp.la
gcc -m32 -O2 -fomit-frame-pointer -mtune=pentiumpro -march=pentiumpro 
-mno-cygwin -o t-bswap.exe t-bswap.o  ./.libs/libtests.a 
/d/eth/tc/proj-v1/native/gmp/src/gmp-4.2.1/.libs/libgmp.a ../.libs/libgmp.a
t-bswap.o:t-bswap.c:(.text+0x4e): undefined reference to `__gmpn_random'
./.libs/libtests.a(trace.o):trace.c:(.text+0x31a): undefined reference 
to `__gmpz_out_str'
./.libs/libtests.a(trace.o):trace.c:(.text+0x4e1): undefined reference 
to `__gmpq_out_str'
./.libs/libtests.a(misc.o):misc.c:(.text+0x446): undefined reference to 
`__gmpz_init'
./.libs/libtests.a(misc.o):misc.c:(.text+0x500): undefined reference to 
`__gmpz_set_ui'
and a lot of other undefined references

Alright, so I used the unchecked built library and tried to compile my 
application. I got the same undefined references:

C:\foobar/cc0Maaaa.o:BigNumber.cpp:(.text+0x40): undefined reference to 
`__gmpz_init'
C:\foobar/cc0Maaaa.o:BigNumber.cpp:(.text+0x59): undefined reference to 
`__gmpz_add'
C:\foobar/cc0Maaaa.o:BigNumber.cpp:(.text+0x72): undefined reference to 
`__gmpz_init_set'
C:\foobar/cc0Maaaa.o:BigNumber.cpp:(.text+0x9a): undefined reference to 
`__gmpz_init'
C:\foobar/cc0Maaaa.o:BigNumber.cpp:(.text+0xb3): undefined reference to 
`__gmpz_set'
C:\foobar/cc0Maaaa.o:BigNumber.cpp:(.text+0xc5): undefined reference to 
`__gmpz_clear'
C:\foobar/cc0Maaaa.o:BigNumber.cpp:(.text+0xd7): undefined reference to 
`__gmpz_clear'
and so on...

So, obviously the gmp.a archive misses some objects. So I added 
libmpz.a, libmpq.a, libmpn.a as well as the 
"-Wl,--allow-multiple-definition" flag to the compilation of my 
application and now it works.

So my questions:

1. Is there a bug in the build process of gmp 4.2.1 on mingw? I can work 
with my workarounds but really don't feel comfortable with an unchecked 
lib with a lot of duplicate objects in it

2. What is libgmpxx.a here for? Although I'm working with the C++ 
interface, I can omit that lib and my final executable works (on Windows 
and Linux).

3. I think there's another bug with static archives (on Windows and 
Linux): Compiling an application with -lgmp and -lgmpxx fails with 
undefined references (really on both platforms). My workaround is to 
completely link these archives into my application ("-Wl,--whole-archive 
-lgmp -lgmpxx -Wl,--no-whole-archive"). That works but shouldn't be 
required...


I'd be glad for feedback and I'm willing to test patches.
Marco


More information about the gmp-discuss mailing list