GMP (Gnu Multi-Precision Arithmetic library) and MPFR (Multi-Precision Floating-Point with Rounding) libraries are prerequisites for bootstrapping the GCC-4.x.x compiler suite. Many modern Unix/Linux systems may have compatible GMP and MPFR library versions already installed; however, if the libraries are not present or the versions are too old, you will need to download either a binary package for your system or the source tarball and compile them yourself. When in doubt, download the sources and compile them yourself to ensure that you have the latest, fastest, and most bug-free libraries.
Once you've downloaded the source tarballs from the websites listed in my previous post and expanded them in a build directory, be sure to read the README and INSTALL text file for the latest requirements and instructions for building the libraries. Both libraries use an Autotools (autoconf, automake, etc.) generated configure script to generate a Makefile for compiling. Make sure to run "./configure --help" in a terminal to see all available configure options. Both GMP and MPFR have options for building shared and static libraries. If you decide to build static-only libraries or if you think you may want to explicitly link a static library into a shared binary, make sure you put "--with-pic" in the list of configure options. Also, you may want to make sure the proper compiler is used to build the libraries by setting the environment variables for them (CC,CXX,FC,CFLAGS,etc.) as described in the "./configure --help" output.
Below are the configure options I used on an AMD Opteron cluster running CentOS 4.4:
GMP:
> ./configure --prefix=/usr/local/gmp422-mpfr231 \
--disable-shared --enable-static --with-pic \
--infodir=/usr/share/info --mandir=/usr/share/man
> make check
> su root
> make install
In this configuration for GMP, I set the installation directory with the '--prefix=/usr/local/gmp422-mpfr231' option. This allows me to keep matching versions together while retaining other version on the system. Also, I disabled building shared libraries to simplify executing on other computers the programs that link against GMP. Using the '--with-pic' option allows the static GMP library to be linked into executables that also link against shared libraries. And finally I included the '--infodir=/usr/share/info --mandir=/usr/share/man' options to install the man and info files in the proper directories for my system.
Compiling MPFR is similar to GMP with the addition of the '--with-gmp=/usr/local/gmp422-mpfr231' option to point to the location of our new GMP library:
MPFR:
> ./configure --prefix=/usr/local/gmp422-mpfr231 --with-gmp=/usr/local/gmp422-mpfr231 --with-pic --disable-shared --enable-static
> make check
> su root
> make install
Congratulation! You are now ready to bootstrap GCC-4.x.x. There are a lot of issues to cover with bootstrapping GCC so I may have to cover that in several posts.
Have a Happy New Year!
Wednesday, December 31, 2008
Subscribe to:
Posts (Atom)