## 2 Installing MPFR ¶

The MPFR library is already installed on some GNU/Linux distributions, but the development files necessary to the compilation such as `mpfr.h` are not always present. To check that MPFR is fully installed on your computer, you can check the presence of the file `mpfr.h` in `/usr/include`, or try to compile a small program having `#include <mpfr.h>` (since `mpfr.h` may be installed somewhere else). For instance, you can try to compile:

    #include <stdio.h>
    #include <mpfr.h>
    int main (void)
    {
      printf ("MPFR library: %-12s\nMPFR header:  %s (based on %d.%d.%d)\n",
              mpfr_get_version (), MPFR_VERSION_STRING, MPFR_VERSION_MAJOR,
              MPFR_VERSION_MINOR, MPFR_VERSION_PATCHLEVEL);
      return 0;
    }

with

    cc -o version version.c -lmpfr -lgmp

and if you get errors whose first line looks like

    version.c:2:19: error: mpfr.h: No such file or directory

then MPFR is probably not installed. Running this program will give you the MPFR version.

If MPFR is not installed on your computer, or if you want to install a different version, please follow the steps below.

### 2.1 How to Install ¶

Here are the steps needed to install the library on Unix systems (more details are provided in the `INSTALL` file):

1. To build MPFR, you first have to install GNU MP (version 5.0.0 or higher) on your computer. You need a C compiler, preferably GCC, but any reasonable compiler should work (C++ compilers should work too, under the condition that they do not break type punning via union). And you need the standard Unix ‘`make`’ command, plus some other standard Unix utility commands.

   Then, in the MPFR build directory, type the following commands.

2. ‘`./configure`’

   This will prepare the build and set up the options according to your system. You can give options to specify the install directories (instead of the default `/usr/local`), threading support, and so on. See the `INSTALL` file and/or the output of ‘`./configure --help`’ for more information, in particular if you get error messages.

3. ‘`make`’

   This will compile MPFR, and create a library archive file `libmpfr.a`. On most platforms, a dynamic library will be produced too.

4. ‘`make check`’

   This will make sure that MPFR was built correctly. If any test fails, information about this failure can be found in the `tests/test-suite.log` file. If you want the contents of this file to be automatically output in case of failure, you can set the ‘`VERBOSE`’ environment variable to 1 before running ‘`make check`’, for instance by typing:

   ‘`VERBOSE=1 make check`’

   In case of failure, you may want to check whether the problem is already known. If not, please report this failure to the MPFR mailing-list ‘`mpfr@inria.fr`’. For details, see Reporting Bugs.

5. ‘`make install`’

   This will copy the files `mpfr.h` and `mpf2mpfr.h` to the directory `/usr/local/include`, the library files (`libmpfr.a` and possibly others) to the directory `/usr/local/lib`, the file `mpfr.info` to the directory `/usr/local/share/info`, and some other documentation files to the directory `/usr/local/share/doc/mpfr` (or if you passed the ‘`--prefix`’ option to `configure`, using the prefix directory given as argument to ‘`--prefix`’ instead of `/usr/local`).

### 2.2 Other ‘make’ Targets ¶

There are some other useful make targets:

- ‘`mpfr.info`’ or ‘`info`’

  Create or update an info version of the manual, in `mpfr.info`.

  This file is already provided in the MPFR archives.

- ‘`mpfr.pdf`’ or ‘`pdf`’

  Create a PDF version of the manual, in `mpfr.pdf`.

- ‘`mpfr.dvi`’ or ‘`dvi`’

  Create a DVI version of the manual, in `mpfr.dvi`.

- ‘`mpfr.ps`’ or ‘`ps`’

  Create a PostScript version of the manual, in `mpfr.ps`.

- ‘`mpfr.html`’ or ‘`html`’

  Create a HTML version of the manual, in several pages in the directory `doc/mpfr.html`; if you want only one output HTML file, then type ‘`makeinfo --html --no-split mpfr.texi`’ from the ‘`doc`’ directory instead.

- ‘`clean`’

  Delete all object files and archive files, but not the configuration files.

- ‘`distclean`’

  Delete all generated files not included in the distribution.

- ‘`uninstall`’

  Delete all files copied by ‘`make install`’.

### 2.3 Build Problems ¶

In case of problem, please read the `INSTALL` file carefully before reporting a bug, in particular section “In case of problem”. Some problems are due to bad configuration on the user side (not specific to MPFR). Problems are also mentioned in the FAQ https://www.mpfr.org/faq.html.

Please report problems to the MPFR mailing-list ‘`mpfr@inria.fr`’. See Reporting Bugs. Some bug fixes are available on the MPFR 4.2.2 web page https://www.mpfr.org/mpfr-4.2.2/.

### 2.4 Getting the Latest Version of MPFR ¶

The latest version of MPFR is available from https://ftp.gnu.org/gnu/mpfr/ or https://www.mpfr.org/.