1 Install GMP

1.1 What is GMP

1.2 Where is GMP

1.3 On Windows

1.3.1 Install “MinGW” and “MSYS”

  • Here is an instruction for installation
  • Download MinGW for GNU C/C++ compiler on Windows
    • MinGW: Minimalist GNU for Windows
    • Install (say “D:\mingw”)
    • Choose the first, the second and the last components
  • Download MSYS
    • MSYS: Minimal SYStem, which is sub-system of MinGW, and it is a bash running on Windows
    • Install it to same Path (say D:\mingw)
    • Choose Y in the first option
    • Choose the same path of MinGW (say D:\mingw) in the second option
  • Using MinGW conbining MSYS, one can create both terminal and GNU compiler OS on Windows, which mimicks Linux OS

1.3.2 Install gmp

  • Installing
    • Click msys and type (waite long time)
    • If enable C++
    • make
    • After done, you can see “libgmp.dll.a” and so on in sub-directory “.libs”
    • If error says “can not find libgmp-10.dll”, copy it (locate in “path\gmp.libs”) into “C:/Windows64” or “C:/Windows32” depending your system platform
  • Add below header in your C files

1.3.3 Setup your environment

1.4 On Mac (Linux)

1.4.1 Install gmp

1.4.2 Setup your environment for GCC

  • Default lib is “/usr/local/lib” and “/usr/local/incude”
  • Do not need setup environment if not specifying a Path in “./configure”

1.5 On Ubuntu

1.5.1 Install gmp

  • Similar to on Mac (say 1.2 On Mac)
  • You may need install “m4”
    • Install m4
  • The default path “./configure” is “/usr/local”, which is same as MacOS
  • But Ubuntu search default path is “/usr/lib”
    • You can set path

    1.5.1 Setup your environment for GCC

2 Setting Compiler

2.1 VS2010 On Windows

  • Setting VS2010
  • Right click your project (say “project_1”), click “Properties”
    • Setting “C/C++ General”, add “D:\GMP\gmp6.1.2” C/C++ General
    • Setting “Linkage General”, add “D:\GMP\gmp6.1.2\.libs;%(AdditionalLibraryDirectories)” Linkage General
    • Setting “Linkage Input”, add “libgmp.dll.a” Linkage Input

2.2 Xcode on Mac/Ubunto

  • Setting Xcode on “Build Settings”
  • Click your project (say “project_1”), click “Build Settings”
    • setting “Other Linkage Flags” to be “-lgmp”
    • Setting “Header Search Paths” to be “/usr/local/include”
    • Setting “Library Search Paths” to be “/usr/local/lib”
    • setting above Settings

3 GCC compiling

  • Compile C/C++ file to an executable file on different platforms
    • All platforms are similar if your gcc environment is set correctly, except for the arguments order.
    • It only depends on gcc/g++
  • It is simple for foo.c including gmp.h
  • Or for foo.cpp including gmpxx.h
  • An example to calculate in add.c
  • add.c
  • Compile on Mac, and then get “add.exe”
  • Compile on Linux. I run this on HPCC of MSU, in which the gmp has been installed.

4 Compile on VS 2010