AndroidDev
AndroidDev

Reputation: 21237

Compiling GMP Library on Windows

I've downloaded and extracted the files for the GMP library. My objective is to use this library working with my c++ code with code::blocks as my IDE. I have verified that there is a makefile among the files that I extracted. In fact, there are two make files, makefile.am and makefile.in.

Assuming that these files are what I need, I open a command prompt and navigate to the folder where these makefiles are stored (c:\cpplibs\gmp). From there, I type 'make' and hit enter with the expectation that this will compile the library and I can then link to it from code::blocks.

However, I immediately get an error message from the command prompt:

'make' is not recognized as an internal or external command, operable program or batch file.

I checked the Path variable and the path where my make.exe file is stored is in this string, so I don't think that is the problem. I haven't used Make before in a Windows environment, so I'm stuck. Am I using Make correctly here? Does anyone see what I am doing wrong?

Thanks!

(edit: I'm posting a couple of screen shots to show how I have Make set up and that the Path variable points to it)

enter image description here

enter image description here

Upvotes: 0

Views: 1033

Answers (2)

MSH
MSH

Reputation: 425

I make the compilation in windows by using instructions from this site:

you can find all the files to download from this site: https://github.com/MachineCognitis/Math.Gmp.Native/tree/master/Math.Gmp.Native/Dependencies

Building the GNU MP Library on Windows Install MSYS2.

On a 64-bit computer, install msys2-x86_64-20161025.exe, and on a 32-bit computer, install msys2-i686-20161025.exe. You can also check for a more recent version of MSYS2 here. Install MSYS2 to its default location.

After installation, you need to updates MSYS2 packages. From the Windows Start Menu, start MSYS2 MSYS. In the shell command window, enter the command:

pacman -Syuu

and follow instructions. You will have to close the command window, reopen a new one, and reenter the command pacman -Syuu.

Finally, in order to build software, you need to install a number of packages with the command:

pacman -S --needed base-devel mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain git subversion mercurial mingw-w64-i686-cmake mingw-w64-x86_64-cmake

run from the same command window as in the previous step.

To build 32-bit software, use the MSYS2 MinGW 32-bit command from the Windows Start Menu, and for 64-bit software, use MSYS2 MinGW 64-bit.

Install yasm.

On a 64-bit computer, copy yasm-1.3.0-win64.exe to C:\msys64\usr\bin, and rename it to yasm.exe.

Similarly on a 32-bit computer, copy yasm-1.3.0-win32.exe to C:\msys32\usr\bin, and rename it to yasm.exe.

Build GNU MP.

Create folders C:\Temp\x86 and C:\Temp\x64. These are the folder where the compiled 32-bit and 64-bit versions of GNU MP will be installed. Unzip gmp-6.1.2.tar.bz2 in folder C:\Temp. This puts GNU MP in subfolder gmp-6.1.2.

In each one of the command windows openend with the commands MSYS2 MinGW 32-bit and MSYS2 MinGW 64-bit from the Windows Start Menu, run the commands below:

cd /c/Temp/gmp-6.1.2 ./configure --enable-fat --disable-static --enable-shared --prefix=/c/Temp/x86 or x64 make make check make install

The --prefix specifies the install folder. Note that the Windows C:
drive is specified as the root /C/ folder in the MinGW window. Note also that the configure and make commands are to be run against a fresly uncompressed GNU MP source. The make install command creates libgmp-10.dll in the C:\Temp\x86 and C:\Temp\x64 folders. These two compiled versions of the GNU MP library are to be copied to the x86 and x64 folders of the Math.Gmp.Native Visual Studio projects. They can also be copied directly into the x86 and x64 folders of the bin/Debug or bin/Release folders.

The 32-bit and 64-bit make check commands generate some warnings, but all tests passed successfully.

Upvotes: 0

antlersoft
antlersoft

Reputation: 14751

These are autoconf/automake files rather than regular make files so they won't work without the GNU tools.

Look into getting MinGW to build this, or you might try Cygwin, which can be simpler if you don't mind the cygwin dependency.

Also, the error message is indicating that make is not in your path, despite what you think.

Upvotes: 2

Related Questions