building gmp with MSYS and MinGW for VC++

Sisyphus kalinabears at iinet.net.au
Tue May 4 09:36:40 CEST 2004


Radu Ursu wrote:
> Hi,
> I use MSYS and MinGW to build gmp. I have a couple questions if you are 
> so kind to help me:
> 
> 1) building like this
>   ./configure --disable-static --enable-shared --enable-mpfr
>   make
>   make install
> I got the gmp.dll but the mpfr library comes as libmpfr.a. How should it 
> be built to be used with VC++? Is it possible?
> 

To build a 'libmpfr.lib' that works with VC++, cd to the 'mpfr' 
directory and run:
lib /out:libmpfr.lib *.o

At least that's how I did it .... which doesn't automatically mean that 
it's the best way :-)

I think you'll also need a 'libgmp.lib'. To build it, cd to the '.libs' 
directory and run:
lib /out:libgmp.lib /def:libgmp-3.dll-def

To build an app with VC 7 (.NET) I find I have to run:
cl source.c libmpfr.lib libgmp.lib libc.lib msvcrt.lib

When I dug a little deeper I did find a problem with mpfr in GMP-4.1.3 - 
it compiled nicely, but I got repeated errors involving an undefined 
symbol '_ALLOCA' when I try to compile (using VC 7) a program involving 
mpfr_t's. (I *think* '_ALLOCA' was the name of the undefined symbol .... 
but I'm relying on my memory - which is not a good idea :-)

I also found that when I run my 4.1.2-built mpfr applications using the 
4.1.3 dll, I get a fatal pop-up with the following message:
"The procedure entry point __gmp_tmp_reentrant_alloc could not be
located in the dynamic link library libgmp-3.dll"

(I was hoping the 4.1.3 dll could be used without having to recompile 
anything.)

I think the problems were limited to mpfr and VC 7. That is, I don't 
think the MinGW compiler, or mpz_t's/mpq_t's/mpf_t's are affected -  but 
I haven't yet had time to take a closer look - so I could be wrong. See 
how you get on :-)

Cheers,
Rob


-- 
Any emails containing attachments will be deleted from my ISP's mail 
server before I even get to see them. If you wish to email me an 
attachment, please provide advance warning so that I can make the 
necessary arrangements.



More information about the gmp-discuss mailing list