www.delorie.com/gnu/docs/gmp/gmp_11.html   search  
 
Buy GNU books!


GNU MP 4.1.2

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.1 Headers and Libraries

All declarations needed to use GMP are collected in the include file `gmp.h'. It is designed to work with both C and C++ compilers.

 
#include <gmp.h>

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

 
#include <stdio.h>
#include <gmp.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 GMP must link against the `libgmp' library. On a typical Unix-like system this can be done with `-lgmp', for example

 
gcc myprogram.c -lgmp

GMP C++ functions are in a separate `libgmpxx' library. This is built and installed if C++ support has been enabled (see section 2.1 Build Options). For example,

 
g++ mycxxprog.cc -lgmpxx -lgmp

GMP is built using Libtool and an application can use that to link if desired, see section `Introduction' in GNU Libtool

If GMP 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. Consult your compiler documentation, for instance section `Introduction' in Using and Porting the GNU Compiler Collection.


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright © 2003   by The Free Software Foundation     Updated Jun 2003