[ < ] | [ > ] | [ << ] | [ 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> |
Likewise <stdarg.h>
(or <varargs.h>
) is required for prototypes
with va_list
parameters, such as mpfr_vprintf
.
And for any functions using intmax_t
, you must include
<stdint.h>
or <inttypes.h>
before ‘mpfr.h’, to
allow ‘mpfr.h’ to define prototypes for these functions. Moreover,
users of C++ compilers under some platforms may need to define
MPFR_USE_INTMAX_T
(and should do it for portability) before
‘mpfr.h’ has been included; of course, it is possible to do that
on the command line, e.g., with -DMPFR_USE_INTMAX_T
.
Note: If mpfr.h
and/or gmp.h
(used by mpfr.h
)
are included several times (possibly from another header file), the
aforementioned standard headers should be included before the
first inclusion of mpfr.h
or gmp.h
. For the time being,
this problem is not avoidable in MPFR without a change in GMP.
When calling a MPFR macro, it is not allowed to have previously defined
a macro with the same name as some keywords (currently do
,
while
and sizeof
).
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.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |