To build GMP for x86-64 on Win64 using VS2008, we use the project
files and sources of Dr. Brian Gladman for this task.  I assume you're
on a Win64 computer -- although it's possible to do so on a 32-bit system
as well, so long as your Visual Studio 2008 installation has an x86-64
compiler.

You can get Visual Studio 2008 Express Edition for free from Microsoft
You can get YASM for free from www.tortall.net/projects/yasm

        --------------------------------------------------------

Here is the complete guide to building GMP 4.3.2 using Visual Studio 2008
with the Brian Gladman downloads.  These instructions were current as of
24 December 2009, but the details are subject to change.

(1) The unmodified GMP 4.3.2 sources are in the subdirectory gmp-4.3.2.

(2) There is no official GMP 4.3.2 package from Brian Gladman, but I
    took the latest one he provided, and tweaked it so it works with
    GMP 4.3.2.  I put it in the "gladman" subdirectory of gmp-4.3.2.

(3) If you have the latest YASM in
        \Program Files (x86)\Microsoft Visual Studio 9\VC\bin
    then continue to step 5.  Otherwise you'll need to get YASM...

    Get YASM by going to http://www.tortall.net/projects/yasm
    Click on Download and get the latest version.  At this time
    this is YASM-0.8.0-win64.exe

    Copy the YASM executable to
      C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin
    and RENAME it to yasm.exe

(5) Copy the file gmp-4.3.2\gladman\gmp.4.3.2.vc9\build.vc9\yasm.rules to
      C:\Program Files\Microsoft Visual Studio 9.0\VC\VCProjectDefaults

(6) Copy the Gladman files over the original GMP files.
    From the main gmp-4.3.2 directory, do:

        cd gladman\gmp.4.3.2.vc9
        xcopy /S /I /Y * ..\..

(7) Start Visual Studio 2008 and load the gmp.sln solution
    in gmp.4.3.2\build.vc9

    If you get complaints about yasm.rules, you didn't put it in
    the right place in step (5).

(8) Pick whether you want Debug or Release in the Configuration drop-down.
    Pick x64 in the Platform drop-down.

(9) Pick what architecture you want to target.  Your choices are:
    * AMD64 (AMD x64)    (this is what Mathematica currently uses)
    * GC (generic C)
    From now on, we'll call the architecture you picked [arch].

(10) In Solution Explorer, open the project dll_gmp_[arch] or lib_gmp_[arch]
     depending on whether you want the DLL or static LIB version.

     (Mathematica currently uses the DLL version, dll_gmp_amd64.
      To replicate the current GMP you should select this.)

(11) Building a shared GMP.DLL.  This is the standard for Mathematica.
     Find the project dll_gmp_[arch].  Click on it to select it.

(12) Right-click on the project you selected and pick "Rebuild".

(13) When the build is done, you will have a library (DLL) and
     support files in gmp.4.3.2\build.vc9\dll\x64\{Debug|Release}

     Copy the file GMP.dll over the existing GMP.dll that's in
     the subdirectory SystemFiles/Kernel/Binaries/Windows-x86-64
     relative to Mathematica's $InstallationDirectory.



Note: if you want to use this GMP DLL for your own software, you'll
want to collect the various built files and header files.  These are:

    gmp-4.3.2\build.vc9\dll\x64\Release:  GMP.dll  GMP.lib  GMP.exp  GMP.pdb
    build.vc9\x64:  fib_table.h  mp_bases.h
    gmp-4.3.2:  config.h  gmp-impl.h  gmp-mparam.h  gmp.h  longlong.h

Note also, if you are using this GMP dll in your own software:
    be sure you have changed any place that #includes GMP headers so it does
       #define __GMP_LIBGMP_DLL
    first, since the Gladman versions of config.h fail to define this.




/* Copyright 2010 Wolfram Research, Inc.

This file is part of the build scripts for building the GNU MP Library
for Mathematica on Windows (32-bit).

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or (at your
option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
License for more details.

You should have received a copy of the GNU Lesser General Public License
along with this program.  If not, see http://www.gnu.org/licenses/.  */
