[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
4.1 Headers and Libraries
All declarations needed to use MPFR are collected in the include file ‘mpfr.h’. It is designed to work with both C and C++ compilers. You should include that file in any program using the MPFR library:
#include <mpfr.h> |
Note however that prototypes for MPFR functions with FILE *
parameters
are provided only if <stdio.h>
is included too (before ‘mpfr.h’).
#include <stdio.h> #include <mpfr.h> |
You can avoid the use of MPFR macros encapsulating functions by defining the ‘MPFR_USE_NO_MACRO’ macro before ‘mpfr.h’ is included. In general this should not be necessary, but this can be useful when debugging user code: with some macros, the compiler may emit spurious warnings with some warning options, and macros can prevent some prototype checking.
All programs using MPFR must link against both ‘libmpfr’ and ‘libgmp’ libraries. On a typical Unix-like system this can be done with ‘-lmpfr -lgmp’ (in that order), for example
gcc myprogram.c -lmpfr -lgmp |
MPFR is built using Libtool and an application can use that to link if desired, see GNU Libtool.
If MPFR has been installed to a non-standard location, then it may be necessary to set up environment variables such as ‘C_INCLUDE_PATH’ and ‘LIBRARY_PATH’, or use ‘-I’ and ‘-L’ compiler options, in order to point to the right directories. For a shared library, it may also be necessary to set up some sort of run-time library path (e.g., ‘LD_LIBRARY_PATH’) on some systems. Please read the ‘INSTALL’ file for additional information.