GMP Install Instruction for Windows Platform
Currently Core Library (from v1.4) uses GNU Multiple Precision Arithmetic Library (GMP) as its low level big number package. GMP is a free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating point numbers. As GMP was originally designed to work under Unix platform, there is few information about how to compile and install under Windows platform. I wrote this page to help you simplify installation.
While there are many C/C++ compilers available under Windows Platform, I will only focus on the following 4 compilers/environments: Cygwin GCC, MinGW GCC, Visual C++ 6.0 and .Net which are freely available or widely used. If you have experiences on other compilers, please let me know.
To help your development, GMP 4.1 source distribution and pre-compiled libraries for these environments are provided here for download. It should work for Pentium III or above.
In the following, I assume that you want to download GMP to ${gmp_download}, build GMP at ${gmp_build}, and install GMP to ${gmp_install}
Cygwin & MinGW (Building static GMP library)
cd ${gmp_build}
tar xzvf ${gmp_download}/gmp-x.x.x.tar.gz
cd gmp-x.x.x
./configure --prefix=${gmp_install}
make
make install
cd ${gmp_build}
tar xzvf ${gmp_download}/gmp-x.x.x.tar.gz
cd gmp-x.x.x
./configure --prefix=${gmp_install}
make
make install
For MSYS's earlier version, "make.exe"and "ranlib.exe"in MSYS will fail to process GMP's configure script. To fix this, you can download "make.exe"and "ranlib.exe"to overwrite your old version, then follow step 2-6.
export PATH=${mingw}/bin:$PATH (for bash, sh)
or setenv PATH ${mingw}/bin:$PATH (for csh, tcsh)
cd ${gmp_build}
tar xzvf ${gmp_download}/gmp-x.x.x.tar.gz
# Make a symlink if possible; otherwise try a hard link.
ln -s $ac_rel_source $ac_dest 2>/dev/null ||
ln $srcdir/$ac_source $ac_dest ||
to # Make a symlink if possible; otherwise try a hard link.
#ln -s $ac_rel_source $ac_dest 2>/dev/null ||
ln $srcdir/$ac_source $ac_dest ||
(Add a comment on first "ln -s"so hard link are created instead of symbolic link) cd gmp-x.x.x
./configure --build=pentium3-pc-mingw32 --prefix=${gmp_install}
(replace "pentium3-pc"by your CPU type) make
make install
Cygwin & MinGW (Building dynamic GMP library)
As I mentioned above, GMP cannot build static and shared libraries at the same time and it will only build static library by default. To use dynamic library, i.e DLL under windows platform, you need to add the options "
--disable-static --enable-shared
"when you configure GMP, i.e. run this command: ./configure --prefix=${gmp_install} --disable-static --enable-shared
A windows DLL "cyggmp-3.dll"(Cygwin) or "libgmp-3.dll"(MinGW) will be generated and you can link it with your executable programs as usual under Cygwin & MinGW except that when you run them, you have put these DLLs in some path which is listed in environment variable $PATH. To ensure that these DLLs can be called by a Microsoft Visual C++ program, you must generate an import library (.lib) for them, using Microsoft LIB tool:
cd gmp-x.x.x/.libs
lib /machine:i386 /def:cyggmp-3.dll-def (for Cygwin)
or
lib /machine:i386 /def:libgmp-3.dll-def (for MinGW)
Visual C++ 6.0 & Visual C++ .Net
In Core Library distribution, we provide patch files for building GMP library under Visual C++:
patches/4.1-static
(or patches/4.1-dynamic
for building DLL) to ${gmp_build} gmp.dsw
( gmp.vcproj
for VC++.Net) to build GMP gmp.h
, lib/gmp.lib
, lib/gmpDebug.lib
to build your GMP application. (If you build GMP DLL, then you need gmp.dll
or gmpDebug.dll
for runing your application.) Enjoy!
--Zilin Du (zilin "at"cs.nyu.edu)
Last Update: Jan 12, 2006
http://cs.nyu.edu/exact/core/gmp/