Next: , Previous: , Up: MPIR Basics   [Index]


3.1 Headers and Libraries

All declarations needed to use MPIR are collected in the include file mpir.h. It is designed to work with both C and C++ compilers.

#include <mpir.h>

Note however that prototypes for MPIR functions with FILE * parameters are only provided if <stdio.h> is included too.

#include <stdio.h>
#include <mpir.h>

Likewise <stdarg.h> (or <varargs.h>) is required for prototypes with va_list parameters, such as gmp_vprintf. And <obstack.h> for prototypes with struct obstack parameters, such as gmp_obstack_printf, when available.

All programs using MPIR must link against the libmpir library. On a typical Unix-like system this can be done with ‘-lmpir’ respectively, for example

gcc myprogram.c -lmpir

MPIR C++ functions are in a separate libmpirxx library. This is built and installed if C++ support has been enabled (see Build Options). For example,

g++ mycxxprog.cc -lmpirxx -lmpir

MPIR is built using Libtool and an application can use that to link if desired, see GNU Libtool in GNU Libtool

If MPIR has been installed to a non-standard location then it may be necessary to use ‘-I’ and ‘-L’ compiler options to point to the right directories, and some sort of run-time path for a shared library.