Building GMP
From OSDev Wiki
Contents |
Introduction
As of GCC 4.3.0, the GMP (GNU Multiple Precision Arithmetic Library) library has been made a dependency. That is, you cannot build a GCC Cross-Compiler without it.
GMP is used to provide support for arbitrary-precision mathematical operations on signed integers, rational numbers and floating point numbers. These functions have a number of uses (including cryptography and other security applications), but in this case are being used to provide additional mathematical support to GCC.
Building GMP
NOTE: When building GMP please make sure to uninstall any copies of GMP currently installed. (Under CygWin)
When following the GCC Cross-Compiler tutorial to build GCC version >= 4.3.0, it is necessary to have GMP and MPFR libraries installed.
For the GMP build process, m4 (a macro language interpreter) may also need to be installed. To do this on Cygwin, (re)run the setup program and install Make, GCC and Binutils as usual. On the package selection page, click "view" until the Full package list is displayed. Now, scroll down and select the latest version of m4.
1. Download the latest GNU GMPLib source tarball. Extract the tarball to /usr/src
2. Type the following:
cd /usr/src mkdir build-gmp cd build-gmp ../gmp-x.x.x/configure --prefix=/usr/local make all install
The current GMP documentation reports several problems with compiling GMP and suggests running "make check" to ensure that the test source provided with GMP is built correctly. This seems to mainly occur when GMP is build with HP's bundled compilers and Apple's GCC releases. I have tested the above configuration which appears to work nicely in Cygwin but you may like to run "make check" to ensure that everything compiled correctly.
Building GMP Shared Library
NOTE: It is not necessary to build GMP as a shared library to build GCC. You may skip this step unless you have a special need for a shared library.
NOTE: When building GMP please make sure to uninstall any copies of GMP currently installed. (Under CygWin)
1. Type the following:
cd /usr/src mkdir build-gmp-shared cd build-gmp-shared ../gmp-x.x.x/configure --prefix=/usr/local --disable-static --enable-shared make all install
3. Again please check the install:
make checkIf all goes well you will have the GMP shared library.
Building GCC
NOTE: Follow the Building MPFR tutorial before completing this step.
When you come to the GCC build phase of the Cross-Compiler Tutorial, specify the following GCC command-line to ensure that GCC is using the correct (newly compiled) versions of GMP and MPFR:
../gcc-4.3.0/configure --target=$TARGET --prefix=$PREFIX --disable-nls \ --enable-languages=c,c++ --without-headers --with-gmp=/usr/local --with-mpfr=/usr/local make all-gcc install-gcc
If building an environment without C++, you can leave out c++ out from the --enable-languages switch.
See Also
Articles
- GCC Cross-Compiler - the original cross-compiler tutorial.
- Building MPFR - how to configure and compile MPFR.
External Links
GMP - the GMP library home page.
Building GMP for Win32 Platforms - Tutorial on building GMP for Win32 Platforms (MinGW/CygWin).
