help:use GMP in VC++

Sam Rawlins sam.rawlins at
Mon May 10 01:19:50 CEST 2010

On Sun, May 9, 2010 at 4:47 AM, himanshu jain <special.himanshu at>wrote:

> Hi,
>   I am new to both GMP and VC++. I want to do some large number arithmetic
> of cryptography.I found the link
> In this link i found four steps for windows under the heading  Visual C++
> 6.0 & Visual C++ .Net

Hi Himanshu,
  If you are new to GMP _and_ VC++, it might be easier to try to compile GMP
with MSYS (MinGW). The link above provides similar instructions for those. I
wrote a post that extends Zillin's documentation a bit:

Feel free to email me if you want more help. I've done this on 32-bit
Windows XP and I'm about to embark on compiling GMP on 64-bit Windows 7.

> In Core Library distribution, we provide patch files for building GMP
> library under Visual C++:
>   1. Download latest GMP and unzip to ${gmp_build}
>   2. Copy all files under patches/4.1-static (or patches/4.1-dynamic for
>   building DLL) to ${gmp_build}
>   3. Open gmp.dsw (gmp.vcproj for VC++.Net) to build GMP
>   4. After building, you can use gmp.h, lib/gmp.lib, lib/gmpDebug.lib to
>   build your GMP application. (If you build GMP DLL, then you need
> gmp.dllor
>   gmpDebug.dll for runing your application.)
> I have done above four steps.In gmp project i have included my file
> (name.c)
> in source files and i am able to compile it but unable to build name.exe.
> Please help me with how to use GMP in VC++ 6.0. I have windows vista.
> Also i have form a new project in vc++ and  include gmp.h in header file
> and
> include library gmp.lib and gmpDebug.lib. I am able to compile and build
> both the below program
> #include<stdio.h>
> #include<conio.h>
> #include<gmp.h>
> #include<math.h>
> void main()
> {
>    mpz_t p,q,phi;
>    printf("enter p and q");
>    gmp_scanf("%Zd%Zd\n",p,q);
>    mpz_mul(phi,p-1,q-1);
> }
> but the problem is when I input a large number from console it gave some
> exception (means GMP is not working) while on other hand i am able to
> output
> a large no (2^1024) .
> Please help me and let me know if i am not clear at any point.
> Thanks & Regards
> Himanshu
> _______________________________________________
> gmp-discuss mailing list
> gmp-discuss at

Sam Rawlins

More information about the gmp-discuss mailing list