1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
|
Installing MPFR
===============
0. You first need to install GMP. See <http://www.swox.com/gmp/>.
MPFR requires GMP version 4.1 or later.
1. Extract the files from the archive.
2. It is strongly advised to apply the latest patches (if this has
not been done yet), e.g.
wget http://www.mpfr.org/mpfr-2.2.1/patches
patch -N -Z -p1 < patches
or
curl http://www.mpfr.org/mpfr-2.2.1/patches | patch -N -Z -p1
3. In the MPFR directory, to detect your system, type:
./configure
possibly with options (see below).
4. To build the library, type:
make
5. To check the built library (runs the test files), type:
make check
6. To install it (default "/usr/local" | see "--prefix" option), type:
make install
If you installed MPFR (header and library) in directories that are
not searched by default by the compiler and/or linking tools, then,
like with other libraries, you may need to set up some environment
variables such as C_INCLUDE_PATH (to find the header mpfr.h),
LIBRARY_PATH (to find the library), and if the shared library has
been installed, LD_LIBRARY_PATH (before execution) or LD_RUN_PATH
(before linking); this list is not exhaustive and some environment
variables may be specific to your system. "make install" gives some
instructions; please read them. You can also find more information
in the manuals of your compiler and linker. The MPFR FAQ may also
give some information.
Remember that if you have several MPFR (or GMP) versions installed
(e.g., one with the system, and one, newer, by you), you will not
necessarily get a compilation/linking error if a wrong library is
used (e.g., because LD_LIBRARY_PATH has not been set correctly).
But unexpected results may occur.
Under Mac OS X, if the shared library was not installed and you use
Apple's linker (this is the default), you will also need to provide
the -search_paths_first linker flag ("-Wl,-search_paths_first" when
you link via gcc) to make sure that the right library is selected,
as by default, Apple's linker selects a shared library preferably,
even when it is farther in the library paths. We recall that if a
wrong library is selected due to this behavior, unexpected results
may occur.
Building the documentation
==========================
To build the documentation in various formats, you may first need to
install recent versions of some utilities such as texinfo.
* Type "make info" to produce the documentation in the info format.
* Type "make dvi" to produce the documentation in the DVI format.
* Type "make mpfr.ps" to produce the documentation in the Postscript format.
Building MPFR with internal GMP header files
============================================
MPFR built with internal GMP header files is a bit faster,
so you may want to build it with them. Just do this in step 1:
./configure --with-gmp-build=GMPBUILD
where GMPBUILD is the GMP build directory.
The needed header files are:
gmp-impl.h, longlong.h and all the necessary headers to use them.
./configure options
===================
--prefix=DIR installs MPFR headers and library in DIR/include and
DIR/lib respectively (the default is "/usr/local").
--with-gmp-include=DIR assumes that DIR contains gmp.h [, gmp-impl.h, ...]
--with-gmp-lib=DIR assumes that DIR contains libgmp.a
--with-gmp-build=DIR assumes that DIR contains the source of GMP.
same as --with-gmp-lib=DIR/.libs
and --with-gmp-include=DIR
Try to set CFLAGS to GMP's one.
--with-gmp=DIR assumes that DIR is where you have installed GMP.
same as --with-gmp-lib=DIR/lib
and --with-gmp-include=DIR/include
Warning! Do not use these options if you have
CPPFLAGS and/or LDFLAGS containing a -I or -L
option with a directory that contains a GMP
header or library file, as these options just
add -I and -L options to CPPFLAGS and LDFLAGS
*after* the ones that are currently declared,
so that DIR will have a lower precedence.
--enable-assert build MPFR with assertions.
--enable-thread-safe build MPFR as thread safe.
--enable-shared build shared libraries.
Run "./configure --help" to see the other options (autoconf default options).
In case of problem
==================
If you can, go to the MPFR page for this version, where you could
find something to solve the problem, or to see if it has already
been reported:
http://www.mpfr.org/mpfr-2.2.1/
If the "configure" fails, please check that the C compiler and its
options are the same as those for the GMP build (specially the ABI).
You can see the latter with the following:
grep "^CC\|^CFLAGS" GMPBUILD/Makefile
Then type (for example, under a sh-compatible shell):
./configure --with-gmp-include=GMPBUILD --with-gmp-lib=GMPINSTALL/lib \
CC=<C compiler> CFLAGS=<compiler options>
And continue the install.
On some architectures, you should provide further options to match
those used by GMP, for example, on powerpc-aix:
make AR="ar -X64"
On some architectures, try with "gmake" (GNU make) instead of "make".
Problems have been reported with the Tru64 make.
Try to build MPFR with/without GMP internal files.
If the build was ok, but the tests failed to link with GMP, it is usually
because PREFIXDIR/lib is used by the static linker but not by the shared
linker (where PREFIXDIR is the directory given in --prefix, or /usr/local
if --prefix wasn't used). There are two solutions:
1. setenv LD_LIBRARY_PATH /usr/lib:PREFIXDIR/lib [csh/tcsh]
or export LD_LIBRARY_PATH=/usr/lib:PREFIXDIR/lib [bash/zsh/...]
2. Or run MPFR's configure with "--with-gmp=/usr/local"
so that libtool is able to fix this problem.
If you can't solve your problem, you could contact us at <mpfr@loria.fr>,
indicating the machine and operating system used (uname -a), the compiler
and version used (gcc -v if you use gcc), the compile options used if any,
the version of GMP and MPFR used and a description of the problem
encountered. Please send us also a log of the installation (config.log).
Note that even if you can build MPFR with a C++ compiler, you can't run
the test suite: C and C++ are not the same language!
You should use a C compiler instead.
Notes on Windows 32
===================
1 - We advise to use mingw (http://www.mingw.org/), which is simpler and
less demanding than Cygwin. Contrary to Cygwin, it also provides native
windows code. The binaries compiled with Cygwin require a dynamic
library (cygwin.dll) to work; there is a Cygwin option -mno-cygwin to
build native code, but it may require some non-portable tricks.
2 - If you just want to make a binary with gcc, there is nothing to do:
GMP, MPFR and the program compile exactly as under Linux.
3 - If you want to make libraries to work under another Windows compiler
like Visual C / C++, the "trick" is that the unix-like *.a files created
by gcc are entirely compatible with the Windows *.lib files. So you just
have to rename the *.a files into *.lib.
With gmp-4.1.3, the only remaining problem seems to be the "alloca" calls
in GMP. Configuring GMP and MPFR with --enable-alloca=malloc-reentrant
should work (if you build MPFR with GMP internal files).
Or you could add the library
"$MINGWIN$/lib/gcc-lib/mingw32/$VERSION$/libgcc.a"
to your project: it contains all the extra-functions needed by a program
compiled by gcc (division of 64 bits integer, bcopy, alloca...).
Of course, include it if and only if your compiler is not gcc.
Notes on Windows 64
===================
MPFR has not been tested on Windows 64.
|