gmp, mpfr, Windows port
Sisyphus
kalinabears at iinet.net.au
Tue Nov 2 04:34:33 CET 2004
Andreas Fabri wrote:
>
> Hello,
>
> I work in the CGAL project, which makes an open source
> library where the user can choose the type of arithmetic
> for coordinates of geometric objects. One option is
> the rational number type of GMP and we then use mpfr
> to compute enclosing double intervals for rational numbers,
> in order to do interval arithmetic.
>
> CGAL is across platform library, which particularly means
> also supporting Windows compilers. The proposed solution
> in this forum is to use mingw and g++ in order to
> create the dll, and to use the Microsoft lib tool
> to create the lib. For mpfr we got the recipe to
> create the .a and to rename it to .lib
> Doing this we encountered problems with missing
> memory allocation functions, and there a suggestion
> on this mailing list is to also link libgcc.a from
> mingw, even if one uses Visual C++. This compiles
> and links, but the executables using it often crash
> as soon as we use mpfr.
>
> The first time that our testsuite worked without
> crashing, was with Brian Gladman's approach.
>
>
> Do you see a way to better integrate your work,
> because as it is now is really hard for your users.
> * mpfr is not up to date in the gmp distribution.
> * mpfr does not generate a dll (Brian has patches
> for this).
> * I recently got a mail announcing a
> release candidate for mpfr. Now I have to do
> wait for Brian to redo his changes, unless the
> mpfr folks incorporate his patchs in their code.
>
> Yes this is work, but taking into account that
> Windows is a major platform (if we like it or
> not), it seems worth the effort for the success
> of "arithmetic without limitations".
>
I now build GMP as a static library with MinGW and MSYS because it
builds flawlessly that way - but such a build does not seem to transfer
across very well to MSVC (both 6.0 and 7.0). I keep getting "unresolved
external symbols".
So I built GMP-4.1.4 as a dynamic lib using MinGW and MSYS.
./configure --disable-static --enable-shared
make
Running make check builds the test executables in the wrong place - so I
transferred them to the correct location and re-ran make check.
Eventually I got to run all of the tests - 2 of which failed. I
submitted a bug report about all of this a few days ago. I suspect the
bugs are in 'make check' rather than in the GMP library because, like I
said, if I build as a static library, everything (including 'make
check') proceeds flawlessly.
I then copy gmp.h into MinGW/include, VC6/include and VC7/include.
I then copy libgmp.dll.a into MinGW/lib/libgmp.a
And I copy 'libgmp-3.dll' to a folder that's in the system path.
Then, using VC7 I run:
lib /def:libgmp-3.dll-def /out:libgmp.lib
and copy the resultant 'libgmp.lib' into VC7/lib.
Then, using VC6 I run:
lib /def:libgmp-3.dll-def /out:libgmp.lib
and copy the resultant 'libgmp.lib' into VC6/lib.
Then, back in the MSYS shell, I build mpfr from mpfr-2.1.0-rc2:
./configure
make
make check
Then using VC7 in the mpfr build directory, I run:
lib /out:libmpfr.lib *.o
and copy the resultant 'libmpfr.lib' into VC7/lib
Then using VC6 in the mpfr build directory, I run:
lib /out:libmpfr.lib *.o
and copy the resultant 'libmpfr.lib' into VC6/lib
Then, with both VC6 and VC7 I can build mpfr apps with:
cl mpfr_test.c libmpfr.lib libgmp.lib libgcc.lib
('libgcc.lib', as you know, has been copied from MinGW's 'libgcc.a'.)
Seems to work ok for me - though one script hardly constitutes a
thorough test :-)
(I hardly ever use the Microsoft compilers.)
I get some warnings along the way with VC7 - maybe there's something
lurking beneath the surface just waiting to bight. Do you have a script
that breaks the above procedure ? If you've got a script or 2 that would
provide a thorough work out, I'd be interested to give them a run. (I
run mostly perl scripts - don't have much in the way of C programs.)
With VC6 I don't think there were any warnings issued at any stage.
Admittedly it's a little kludgy, but it's fairly straightforward and the
copying and 'lib' commands could be automated with a simple perl script
or batch file.
Anyway - that's filled in *my* afternoon quite nicely .... hope there's
something there that helps.
Cheers,
Rob
More information about the gmp-discuss
mailing list