Installing libgmp.a under win32/win95 (Windows 95)
Getting the GNU Multiprecision Library (GMP) to work on a windows machine was a difficult process for me. The aim of this web page is to make it easy for you.
What is GMP?? The Gnu Multiprecision Library is a library of highly optimized C routines for doing arithmetic with large numbers - up to millions of digits. There are functions for basic arithmetic, and for advanced number-theoretic computations. Very useful for cryptographic, research or other applications. There are other similar packages available, but GMP has highly optimized routines written in assembly language for all the main internal loops, which should make it extremely fast.
How much does it cost? A total of $0.00. It is distributed under a license similar to the GNU public license, which allows you, once you have obtained the product, to
At least, that's the essence of it. More details may be found at The GNU site itself, aka the Free Software Foundation.
- Make and use as many copies as you like, to use as you like, or to give away or even sell, as long as:
- You make it clear to others that they can obtain the source code if they want
- Those who obtain the product have the same rights (and responsibilities) that you do.
- Modify and distribute the product as you please, providing that
- It is clear that you are the author (and therefore responsible for) the modifications, and
- Those who obtain your modified version have the same rights (and responsibilities) to it as you did to the original.
How do I obtain the GMP library? The FSF makes the source code available. It may be obtained from This FTP site. Look for a file called gmp-?.?.tar.gz (the ?'s are numbers). You will then need to compile it. If you are on a Unix or Linux machine, you should stop reading here and read the documentation that came with GMP.
Installing GMP under Windows The below applies specifically to version 2.0.2 of GMP. Basically, although the documentation claims that it is easy to install, it is not. What follows is an attempt to make it easier. I owe a great debt of gratitude to Cliff Bergman of Iowa State University, who had traveled this road before me, and who helped me navigate the final stretch.
If you want to compile the library yourself then read on. If not, you may skip the next few paragraphs, to the section entitled "Sound Too Troublesome?"
You will need the DJGPP compiler This is also obtainable under the GNU public license, for a cost of $0.00, but will take a while to download. The DJGPP homepage is here. Fortunately, djgpp is easy to install under windows. Use their zip picker webpage to choose what files you require. I found DJGPP easy to install, just by carefully following the provided instructions.
You will need to obtain GMP (of course). The link to the source files is given above (see the paragraph on "How do I obtain..." above). I recommend unzipping it with WINZIP, unless you want to learn all about gz and tar files and try to find another way to deal with them in windows. [NB - Winzip is Shareware, which means it is NOT "free" like GMP or DJGPP. You are required to pay for it if you like it and want to keep using it].
GMP-2.0.2 comes with a batch file, make.bat, which is supposed to set up GMP for you once djgpp is installed. Unfortunately, it doesn't work. This may be fixed in a later version of GMP, but in the meantime, this patch file (38712 bytes) will fix all the bugs. Unzip it into the same directory into which gmp-2.0.2.tar.gz was unzipped. If you are asked if you want to replace files, say "Yes". If you are not using winzip, make sure you keep the directory structure, or the patch won't work.
Finally run the batch file make.bat. (This should now be the modified batch file found in the patch). It should build the library. Copy the file libgmp.a into the LIB directory of your compiler, and the gmp.h into the INCLUDE directory. Your GMP library is now installed.
Sound too troublesome? Then I also provide what I searched for in vain on the 'net. a pre-compiled libgmp.a for Windows or MS-DOS machines. Here it is: The library itself (170266 bytes). This zipfile contains the two files libgmp.a and gmp.h, which should be all your computer needs to use the library, and the file gmp.html, which should be all you need... As mentioned above, copy the file LIBGMP.A into the LIB directory of your compiler, and the GMP.H file into the INCLUDE directory.
Enjoy! If this page has been helpful, please let me know.
Since uploading this page, I realized the following:
- The libgmp.a file I provided is still not a library for windows programs, but rather for a DOS extender environment. It needs to be linked with djgpp. I haven't tried other compilers for dos programs.
- I used RSXNTDJ version 1.6b to create a library libgmpw.a, which is useful for creating genuine windows programs. However, I haven't had time to include this file into the zipfile, or upload the patch that creates it. Sorry.
- So far, nobody (that I know of) has been able to get the libraries to work with MS Visual C++. Three have tried and failed and contacted me. I use the RSXNTDJ compiler to link my library into my programs. Soon (I hope) I will have access to MSVC++. I hope then to have time to get the library working with that package.
- Has anyone tried it with any other compilers, whether successfully or not? Please let me know!
- The highest version of GMP currently available is 3.0.1 (as of this writing). When they include FFT multiplications, I will put an updated library together.