Using GMP in Visual C++

delta trinity deltatrinity@hotmail.com
Wed, 05 Feb 2003 09:24:49 -0500


Hello.  I hope this question is not out of the scope of this discussion 
forum.

It's me again, Deltatrinity (Eric).

Well, I installed Visual C++ and trying to use GMP with it.  I'm sort of a 
newbie there.  I had no problems with Borland C++ but trying to use GMP 
under MSVC, I only get unresolved externals.

I have this simple code:

#include "stdafx.h"
#include "gmp.h"

int _tmain(int argc, _TCHAR* argv[]) //_tmain is generated by MSVC
{
   mpz_t N;
   mpz_init(N);
   gmp_printf("%Zd\n",N);
	return 0;
}

When not specifying any extra files, I get

Linking...
TestEMM.obj : error LNK2019: unresolved external symbol __imp____gmp_printf 
referenced in function _main
TestEMM.obj : error LNK2019: unresolved external symbol __imp____gmpz_init 
referenced in function _main
Debug/TestEMM.exe : fatal error LNK1120: 2 unresolved externals

If I include libgmp-3.dll-def in the linker options module definition files, 
then I get

Linking...
libgmp-3.dll-def : error LNK2001: unresolved external symbol __gmp_0
libgmp-3.dll-def : error LNK2001: unresolved external symbol 
__gmp_allocate_func

[snip]

libgmp-3.dll-def : error LNK2001: unresolved external symbol __gmpz_urandomm
libgmp-3.dll-def : error LNK2001: unresolved external symbol __gmpz_xor
Debug/TestEMM.lib : fatal error LNK1120: 382 unresolved externals
LINK : fatal error LNK1141: failure during build of exports file

And I can't seem to make it work.

Anybody successfully compiled under Visual C++ (by the way, I'm building 
Win32 console apps in Visual C++ .NET)

Thenks.

_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE*  
http://join.msn.com/?page=features/junkmail