Building MPFR

From OSDev Wiki

Jump to: navigation, search

Contents

Introduction

As of GCC 4.3.0, the MPFR (Multiple Precision Floating Point) library have been made a dependency. That is, you cannot build a GCC Cross-Compiler without it.

MPFR is used for multiple precision floating point operations with correct rounding. 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 MPFR

NOTE: If you have not already done so, please follow the Building GMP tutorial. MPFR requires GMP.

1. Download the latest GNU MPFR source tarball. Extract the tarball to /usr/src

2. Type the following:

cd /usr/src
mkdir build-mpfr
cd build-mpfr
../mpfr-x.x.x/configure --prefix=/usr/local
make all install

Note that unlike Binutils and GCC, you are only building a host version of GMP and MPFR. This means that if you decide later to build a cross compiler for a second target, you do not need to re-install these libraries.

At this point you should have a working copy of both GMP and MPFR.

Building MPFR Shared Library

Note: It is not necessary to build MPFR as a shared library to build GCC.

1. Type the following:

cd /usr/src
mkdir build-mpfr-shared
cd build-mpfr-shared
../mpfr-x.x.x/configure --prefix=/usr/local --disable-static --enable-shared
make all

2. Again please check the install:

make check

3. Install the shared library:

make install

If all goes well you will have the MPFR shared library.

Building GCC

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.

Shortcuts

Debian

If you are on a Debian-based GNU/Linux system, you can install a single package that will allow you to compile the necessary parts of GCC. This package has dependencies on everything else you will need.

apt-get install libmpfr-dev

See Also

Reported Problems

If during the configuration of the MPFR install, you receive an error complaining about differing versions between gmp.h and libgmp please make sure to uninstall all old copies of GMP before retrying.

Articles

External Links

MPFR - the MPFR library home page.

Personal tools