INSTALL revision 1.1.1.5 1 1.1.1.5 mrg Copyright 1999-2020 Free Software Foundation, Inc.
2 1.1.1.3 mrg Contributed by the AriC and Caramba projects, INRIA.
3 1.1 mrg
4 1.1 mrg This file is part of the GNU MPFR Library.
5 1.1 mrg
6 1.1 mrg The GNU MPFR Library is free software; you can redistribute it and/or modify
7 1.1 mrg it under the terms of the GNU Lesser General Public License as published by
8 1.1 mrg the Free Software Foundation; either version 3 of the License, or (at your
9 1.1 mrg option) any later version.
10 1.1 mrg
11 1.1 mrg The GNU MPFR Library is distributed in the hope that it will be useful, but
12 1.1 mrg WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 1.1 mrg or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 1.1 mrg License for more details.
15 1.1 mrg
16 1.1 mrg You should have received a copy of the GNU Lesser General Public License
17 1.1 mrg along with the GNU MPFR Library; see the file COPYING.LESSER. If not, see
18 1.1.1.5 mrg https://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
19 1.1 mrg 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20 1.1 mrg
21 1.1 mrg
22 1.1 mrg
23 1.1 mrg Installing GNU MPFR
24 1.1 mrg ===================
25 1.1 mrg
26 1.1 mrg Note: In case of problem, please read this INSTALL file carefully before
27 1.1 mrg reporting a bug, in particular Section "In case of problem" below. Some
28 1.1 mrg problems are due to bad configuration on the user side (not specific to
29 1.1 mrg MPFR).
30 1.1 mrg
31 1.1.1.5 mrg 0. You first need to install GMP. See <https://gmplib.org/>.
32 1.1.1.5 mrg MPFR requires GMP version 5.0.0 or later.
33 1.1 mrg
34 1.1 mrg 1. Extract the files from the archive.
35 1.1 mrg
36 1.1.1.2 mrg 2. It is strongly advised to apply the latest patches if this has
37 1.1.1.2 mrg not been done yet and if patches are available. You can check
38 1.1.1.2 mrg on the release page:
39 1.1.1.2 mrg
40 1.1.1.5 mrg https://www.mpfr.org/mpfr-4.1.0/
41 1.1.1.2 mrg
42 1.1.1.2 mrg which may have additional information. The patches can be applied
43 1.1.1.2 mrg with commands like:
44 1.1.1.2 mrg
45 1.1.1.5 mrg wget https://www.mpfr.org/mpfr-4.1.0/allpatches
46 1.1 mrg patch -N -Z -p1 < allpatches
47 1.1.1.2 mrg
48 1.1 mrg or
49 1.1.1.2 mrg
50 1.1.1.5 mrg curl https://www.mpfr.org/mpfr-4.1.0/allpatches | patch -N -Z -p1
51 1.1 mrg
52 1.1 mrg (Those instructions are for the GNU patch command, for example
53 1.1.1.2 mrg /usr/bin/gpatch on Solaris.)
54 1.1 mrg
55 1.1 mrg 3. In the MPFR directory, to detect your system, type:
56 1.1 mrg ./configure
57 1.1 mrg possibly with options (see below, in particular if this step or
58 1.1.1.2 mrg one of the following fails). You should also check whether WARNING
59 1.1.1.2 mrg lines have been output (such a problem may cause a failure in one
60 1.1.1.2 mrg of the following steps).
61 1.1 mrg Note: paths provided in configure options must always be absolute
62 1.1 mrg (relative paths are not supported).
63 1.1 mrg
64 1.1 mrg 4. To build the library, type:
65 1.1 mrg make
66 1.1 mrg
67 1.1 mrg [optional] if you want to tune MPFR for your specific architecture, see
68 1.1 mrg the section "Tuning MPFR" below. Note that for most common architectures,
69 1.1 mrg MPFR includes some default tuning parameters which should be near from
70 1.1 mrg optimal.
71 1.1 mrg
72 1.1 mrg 5. To check the built library (runs the test files), type:
73 1.1 mrg make check
74 1.1 mrg
75 1.1.1.3 mrg Note: If any test fails, information about this failure can be found in
76 1.1.1.3 mrg the tests/test-suite.log file; you should provide this file in your bug
77 1.1.1.3 mrg reports (in addition to other useful information, as mentioned later).
78 1.1.1.3 mrg If you want the contents of this file to be automatically output in case
79 1.1.1.3 mrg of failure, you can set the VERBOSE environment variable to 1 before
80 1.1.1.3 mrg running "make check", for instance by typing:
81 1.1.1.3 mrg VERBOSE=1 make check
82 1.1.1.3 mrg
83 1.1.1.4 mrg 6. [Optional / experimental] Binary distributions may also want to run:
84 1.1.1.4 mrg make check-gmp-symbols
85 1.1.1.4 mrg
86 1.1.1.4 mrg This will check that MPFR does not use GMP internal symbols, which
87 1.1.1.4 mrg could yield failures in case of GMP upgrade without a MPFR rebuild.
88 1.1.1.4 mrg But note that this is a heuristic and might give false positives or
89 1.1.1.4 mrg false negatives. Please report any problem to the MPFR developers.
90 1.1.1.4 mrg End users may also be interested in this check, unless they have
91 1.1.1.4 mrg allowed GMP internals with configure options (see below).
92 1.1.1.4 mrg
93 1.1.1.4 mrg 7. To install it (default "/usr/local" | see "--prefix" option), type:
94 1.1 mrg make install
95 1.1 mrg
96 1.1 mrg If you installed MPFR (header and library) in directories that are
97 1.1 mrg not searched by default by the compiler and/or linking tools, then,
98 1.1 mrg like with other libraries, you may need to set up some environment
99 1.1 mrg variables such as C_INCLUDE_PATH (to find the header mpfr.h),
100 1.1 mrg LIBRARY_PATH (to find the library), and if the shared library has
101 1.1 mrg been installed, LD_LIBRARY_PATH (before execution) or LD_RUN_PATH
102 1.1 mrg (before linking); this list is not exhaustive and some environment
103 1.1 mrg variables may be specific to your system. "make install" gives some
104 1.1 mrg instructions; please read them. You can also find more information
105 1.1 mrg in the manuals of your compiler and linker. The MPFR FAQ may also
106 1.1 mrg give some information.
107 1.1 mrg
108 1.1 mrg Remember that if you have several MPFR (or GMP) versions installed
109 1.1 mrg (e.g., one with the system, and one, newer, by you), you will not
110 1.1 mrg necessarily get a compilation/linking error if a wrong library is
111 1.1 mrg used (e.g., because LD_LIBRARY_PATH has not been set correctly).
112 1.1 mrg But unexpected results may occur.
113 1.1 mrg
114 1.1 mrg Under Mac OS X, if the shared library was not installed and you use
115 1.1 mrg Apple's linker (this is the default), you will also need to provide
116 1.1 mrg the -search_paths_first linker flag ("-Wl,-search_paths_first" when
117 1.1 mrg you link via gcc) to make sure that the right library is selected,
118 1.1 mrg as by default, Apple's linker selects a shared library preferably,
119 1.1 mrg even when it is farther in the library paths. We recall that if a
120 1.1 mrg wrong library is selected due to this behavior, unexpected results
121 1.1 mrg may occur.
122 1.1 mrg
123 1.1 mrg
124 1.1 mrg Building the documentation
125 1.1 mrg ==========================
126 1.1 mrg
127 1.1 mrg To build the documentation in various formats, you may first need to
128 1.1 mrg install recent versions of some utilities such as texinfo.
129 1.1 mrg
130 1.1 mrg * Type "make info" to produce the documentation in the info format.
131 1.1 mrg
132 1.1 mrg * Type "make pdf" to produce the documentation in the PDF format.
133 1.1 mrg
134 1.1 mrg * Type "make dvi" to produce the documentation in the DVI format.
135 1.1 mrg
136 1.1 mrg * Type "make ps" to produce the documentation in the Postscript format.
137 1.1 mrg
138 1.1 mrg * Type "make html" to produce the documentation in the HTML format
139 1.1 mrg (in several pages); if you want only one output HTML file, then
140 1.1.1.2 mrg type "makeinfo --html --no-split mpfr.texi" from the doc directory
141 1.1.1.2 mrg instead.
142 1.1 mrg
143 1.1 mrg
144 1.1 mrg Building MPFR with internal GMP header files
145 1.1 mrg ============================================
146 1.1 mrg
147 1.1 mrg MPFR built with internal GMP header files is a bit faster, so you may want
148 1.1 mrg to build it with them. Just do this in step 1:
149 1.1 mrg
150 1.1 mrg ./configure --with-gmp-build=GMPBUILD
151 1.1 mrg
152 1.1 mrg where GMPBUILD is the GMP build directory. The needed header files are:
153 1.1.1.2 mrg gmp-impl.h, longlong.h and all the necessary headers to use them, which
154 1.1.1.2 mrg may be located either in the GMP source directory or in the GMP build
155 1.1.1.2 mrg directory, in case they are different (MPFR takes care of that, as of
156 1.1.1.2 mrg MPFR 3.1.0).
157 1.1 mrg
158 1.1 mrg Warning: the library obtained in this way may use some internal GMP
159 1.1 mrg symbols, and thus dynamically linking your software with a different
160 1.1 mrg version of GMP might fail, even though it is declared as compatible
161 1.1 mrg by Libtool's versioning system.
162 1.1 mrg
163 1.1 mrg
164 1.1 mrg Tuning MPFR
165 1.1 mrg ===========
166 1.1 mrg
167 1.1.1.4 mrg [For the current GMP version (6.1.0), a Unix-like OS is required.]
168 1.1.1.4 mrg
169 1.1 mrg For this, you need to build MPFR with a GMP build directory (see above).
170 1.1 mrg In the GMP build directory, you also need to go into the "tune" subdirectory
171 1.1 mrg and type "make speed". This will build the GMP speed library, which is used
172 1.1 mrg by the MPFR tuning mechanism.
173 1.1 mrg
174 1.1.1.2 mrg Then go back to the MPFR build directory, go into the "tune" subdirectory and
175 1.1.1.2 mrg type "make tune". This will build an optimized file "mparam.h" for your
176 1.1.1.2 mrg specific architecture.
177 1.1 mrg
178 1.1 mrg
179 1.1 mrg ./configure options
180 1.1 mrg ===================
181 1.1 mrg
182 1.1 mrg --prefix=DIR installs MPFR headers and library in DIR/include and
183 1.1 mrg DIR/lib respectively (the default is "/usr/local").
184 1.1 mrg
185 1.1 mrg --with-gmp-include=DIR assumes that DIR contains gmp.h
186 1.1 mrg --with-gmp-lib=DIR assumes that DIR contains the GMP library
187 1.1 mrg --with-gmp=DIR assumes that DIR is where you have installed GMP.
188 1.1 mrg same as --with-gmp-lib=DIR/lib
189 1.1 mrg and --with-gmp-include=DIR/include
190 1.1 mrg (use either --with-gmp alone or one or both of
191 1.1 mrg --with-gmp-lib/--with-gmp-include)
192 1.1 mrg Warning! Do not use these options if you have
193 1.1 mrg CPPFLAGS and/or LDFLAGS containing a -I or -L
194 1.1 mrg option with a directory that contains a GMP
195 1.1 mrg header or library file, as these options just
196 1.1 mrg add -I and -L options to CPPFLAGS and LDFLAGS
197 1.1 mrg *after* the ones that are currently declared,
198 1.1 mrg so that DIR will have a lower precedence. Also,
199 1.1.1.2 mrg this may not work if DIR is a system directory
200 1.1.1.2 mrg (typically /usr or /usr/local); see below.
201 1.1 mrg
202 1.1 mrg --with-gmp-build=DIR assumes that DIR contains the GMP build directory,
203 1.1 mrg and enables the use of GMP internals (see above).
204 1.1 mrg Warning! This option and the group of options
205 1.1 mrg --with-gmp are mutually exclusive.
206 1.1 mrg
207 1.1 mrg --enable-assert build MPFR with assertions.
208 1.1 mrg
209 1.1 mrg --enable-thread-safe build MPFR as thread safe, using compiler-level
210 1.1.1.5 mrg Thread-Local Storage (TLS). Note: TLS support is
211 1.1 mrg roughly tested by configure. If configure detects
212 1.1 mrg that TLS does not work (because of the compiler,
213 1.1 mrg linker or system libraries), it will output an
214 1.1 mrg error message, telling you to build MPFR without
215 1.1 mrg thread safe. For instance, though Mac OS X uses
216 1.1 mrg GCC, it may not currently support GCC's __thread
217 1.1 mrg storage class.
218 1.1 mrg
219 1.1.1.2 mrg --disable-thread-safe build MPFR without TLS. By default, TLS support
220 1.1.1.2 mrg is detected automatically, and MPFR is built as
221 1.1.1.2 mrg thread safe if supported. However this detection
222 1.1.1.2 mrg is only a heuristic: TLS can be detected as
223 1.1.1.2 mrg supported while its support is incomplete or
224 1.1.1.2 mrg buggy (MPFR tests may fail). In such a case,
225 1.1.1.2 mrg this option is useful.
226 1.1.1.2 mrg
227 1.1.1.5 mrg --enable-decimal-float build conversion functions from/to decimal floats.
228 1.1.1.5 mrg Note that detection by the configure script is
229 1.1.1.5 mrg limited in case of cross-compilation.
230 1.1.1.5 mrg Accepted arguments:
231 1.1.1.5 mrg yes Decimal support is requested and the configure
232 1.1.1.5 mrg script fails if it detects that decimals do not
233 1.1.1.5 mrg work.
234 1.1.1.5 mrg The encoding (BID or DPD) will automatically be
235 1.1.1.5 mrg detected at configure time or at compile time if
236 1.1.1.5 mrg possible (if not, generic code will be used).
237 1.1.1.5 mrg no Decimal support is explicitly disabled.
238 1.1.1.5 mrg auto Decimal support is enabled if the configure script
239 1.1.1.5 mrg detects that it works. This is the default when
240 1.1.1.5 mrg --{enable,disable}-decimal-float is not given.
241 1.1.1.5 mrg bid Decimal support is requested and the encoding is
242 1.1.1.5 mrg assumed to be BID (some check may be done).
243 1.1.1.5 mrg dpd Decimal support is requested and the encoding is
244 1.1.1.5 mrg assumed to be DPD (some check may be done).
245 1.1.1.5 mrg generic Decimal support is requested and the generic code
246 1.1.1.5 mrg is used (mainly for developers).
247 1.1.1.5 mrg
248 1.1.1.2 mrg --enable-gmp-internals allows the MPFR build to use GMP's undocumented
249 1.1.1.2 mrg functions (not from the public API). Note that
250 1.1.1.2 mrg library versioning is not guaranteed to work if
251 1.1.1.2 mrg this option is used. Thus it must not be used in
252 1.1.1.2 mrg binary distributions.
253 1.1.1.2 mrg
254 1.1.1.4 mrg --with-sysroot=DIR Search for dependent libraries within DIR (which
255 1.1.1.4 mrg may be useful in cross-compilation). If you use
256 1.1.1.4 mrg this option, you need to have Libtool 2.4+ on
257 1.1.1.4 mrg the target system. See Libtool 2.4+'s NEWS file.
258 1.1.1.4 mrg
259 1.1.1.5 mrg Note: By default, the configure script tries to set CC / CFLAGS to GMP's
260 1.1.1.5 mrg ones from gmp.h (__GMP_CC / __GMP_CFLAGS) in order to ensure that MPFR is
261 1.1.1.5 mrg built with the same ABI as GMP. The reason is that when GMP is built, it
262 1.1.1.5 mrg may set CC / CFLAGS to select an ABI that is not the default one in order
263 1.1.1.5 mrg to have a better performance. The -pedantic option in GMP's CFLAGS, when
264 1.1.1.5 mrg present (which is the case by default), is removed, because the MPFR
265 1.1.1.5 mrg build system uses some C extensions (when this script detects that they
266 1.1.1.5 mrg are supported) and -pedantic yields too many useless warnings. However,
267 1.1.1.5 mrg this setting from GMP is not guaranteed to work as the configure script
268 1.1.1.5 mrg does some compiler tests earlier, and a conflict may arise. Also, the
269 1.1.1.5 mrg values obtained from GMP may be incorrect for the MPFR build if GMP has
270 1.1.1.5 mrg been built on a different machine; in such a case, the user may need to
271 1.1.1.5 mrg specify CC / CFLAGS, as explained below.
272 1.1 mrg
273 1.1.1.4 mrg Moreover, even without --with-gmp-build and --enable-gmp-internals,
274 1.1.1.4 mrg MPFR might use some GMP internals by mistake. This would be a bug,
275 1.1.1.4 mrg which should be reported to the MPFR developers.
276 1.1.1.4 mrg
277 1.1.1.4 mrg Run "./configure --help" to see the other options (default options
278 1.1.1.4 mrg from Autoconf and Automake).
279 1.1 mrg
280 1.1 mrg
281 1.1.1.2 mrg If 'gmp.h' and 'libgmp' do not match
282 1.1.1.2 mrg ====================================
283 1.1.1.2 mrg
284 1.1.1.2 mrg Under some circumstances, the configure script may output a message
285 1.1.1.2 mrg saying:
286 1.1.1.2 mrg
287 1.1.1.2 mrg 'gmp.h' and 'libgmp' seem to have different versions or
288 1.1.1.2 mrg we cannot run a program linked with GMP (if you cannot
289 1.1.1.2 mrg see the version numbers above). [...]
290 1.1.1.2 mrg
291 1.1.1.2 mrg Even though the configure script does not fail in such a case, this
292 1.1.1.2 mrg message most often indicates a real error, which needs to be avoided.
293 1.1.1.2 mrg Possible causes are:
294 1.1.1.2 mrg
295 1.1.1.2 mrg * The wanted GMP library does not have the same ABI as the one chosen
296 1.1.1.2 mrg to build MPFR. The consequences may be:
297 1.1.1.2 mrg
298 1.1.1.2 mrg - A different GMP library (with the correct ABI) has been found,
299 1.1.1.2 mrg but does not have the same version as 'gmp.h'.
300 1.1.1.2 mrg
301 1.1.1.2 mrg - No other GMP libraries have been found (in this case, no version
302 1.1.1.2 mrg numbers should be printed above the warning message).
303 1.1.1.2 mrg
304 1.1.1.2 mrg This is incorrect and one of the following steps (make, make check)
305 1.1.1.2 mrg will probably fail. GMP (actually gmp.h) now provides CC and CFLAGS
306 1.1.1.2 mrg information to select the correct ABI, so that this problem should
307 1.1.1.2 mrg no longer occur; but if GMP was provided by a binary package, such
308 1.1.1.2 mrg information may not be valid. See the
309 1.1.1.2 mrg
310 1.1.1.2 mrg checking for CC and CFLAGS in gmp.h...
311 1.1.1.2 mrg
312 1.1.1.2 mrg line in the configure output (about the 11th line) and the following
313 1.1.1.2 mrg few ones for more information. You may need to reinstall GMP or to
314 1.1.1.2 mrg provide your own CC and/or CFLAGS. See also the remaining of this
315 1.1.1.2 mrg INSTALL file.
316 1.1.1.2 mrg
317 1.1.1.2 mrg * A configure option like --with-gmp or --with-gmp-include was used
318 1.1.1.2 mrg with a system include directory, e.g. one of the following:
319 1.1.1.2 mrg
320 1.1.1.2 mrg --with-gmp=/usr
321 1.1.1.2 mrg --with-gmp=/usr/local
322 1.1.1.2 mrg --with-gmp-include=/usr/include
323 1.1.1.2 mrg --with-gmp-include=/usr/local/include
324 1.1.1.2 mrg
325 1.1.1.2 mrg GCC (and possibly other compilers) will ignore such a directive for
326 1.1.1.2 mrg include directories (but this rule is not applied for the library
327 1.1.1.2 mrg itself!). This means that the library search paths will be reordered
328 1.1.1.2 mrg as declared, but the specified include directory will still be near
329 1.1.1.2 mrg the end of the include search paths (thus with a low precedence).
330 1.1.1.2 mrg This is not a problem if only one GMP version is installed, but
331 1.1.1.2 mrg otherwise, a wrong gmp.h may be chosen, so that the versions of
332 1.1.1.2 mrg gmp.h and libgmp may not match. The suggestions are the following:
333 1.1.1.2 mrg
334 1.1.1.2 mrg - If you want to use the GMP version under /usr, then you should
335 1.1.1.2 mrg uninstall all the other GMP versions (header and library files)
336 1.1.1.2 mrg that may be seen in the search paths, in particular those under
337 1.1.1.2 mrg /usr/local.
338 1.1.1.2 mrg
339 1.1.1.2 mrg - If you want to use the GMP version under /usr/local, then you
340 1.1.1.2 mrg should uninstall all the other GMP versions (header and library
341 1.1.1.2 mrg files) that may be seen in the search paths, but *NOT* the one
342 1.1.1.2 mrg under /usr (the version under /usr is provided by the OS vendor,
343 1.1.1.2 mrg and changing/removing anything related to it may break your
344 1.1.1.2 mrg system, and /usr should have a lower precedence than /usr/local
345 1.1.1.2 mrg anyway).
346 1.1.1.2 mrg
347 1.1.1.2 mrg To find where GMP versions have been installed:
348 1.1.1.2 mrg
349 1.1.1.2 mrg $ locate libgmp (if you have a locate database)
350 1.1.1.2 mrg
351 1.1.1.2 mrg and if the compiler is GCC:
352 1.1.1.2 mrg
353 1.1.1.2 mrg $ gcc -print-file-name=libgmp.so (under most systems)
354 1.1.1.2 mrg $ gcc -print-file-name=libgmp.dylib (under Mac OS X)
355 1.1.1.2 mrg
356 1.1.1.2 mrg and if this does not work, you may try:
357 1.1.1.2 mrg
358 1.1.1.2 mrg $ gcc -print-search-dirs
359 1.1.1.2 mrg
360 1.1.1.2 mrg * An official GCC version was used under Debian GNU/Linux. Problems
361 1.1.1.2 mrg may come from the fact that Debian chose a different convention
362 1.1.1.2 mrg for library search paths concerning 32-bit and 64-bit libraries.
363 1.1.1.2 mrg A possible problem can be, for instance:
364 1.1.1.2 mrg
365 1.1.1.2 mrg [Debian's GCC, correct library path]
366 1.1.1.2 mrg $ gcc -print-file-name=libgmp.so
367 1.1.1.2 mrg /home/vlefevre/gmp/athlon64/lib/../lib/libgmp.so
368 1.1.1.2 mrg
369 1.1.1.2 mrg [Official GCC, incorrect library path]
370 1.1.1.2 mrg $ gcc-4.3.1 -print-file-name=libgmp.so
371 1.1.1.2 mrg /usr/lib/../lib64/libgmp.so
372 1.1.1.2 mrg
373 1.1.1.2 mrg The solution: use a GCC provided by Debian or add symbolic links
374 1.1.1.2 mrg such as lib64 -> lib (on 64-bit machines) for your library paths.
375 1.1.1.2 mrg
376 1.1.1.2 mrg * The problem may also be temporary and only due to the fact that
377 1.1.1.2 mrg libtool could not be used at this time. This is unlikely, though.
378 1.1.1.2 mrg
379 1.1.1.2 mrg
380 1.1 mrg In case of problem
381 1.1 mrg ==================
382 1.1 mrg
383 1.1 mrg First, look for any warning message in the configure output.
384 1.1 mrg
385 1.1 mrg Several documents may help you to solve the problem:
386 1.1 mrg * this INSTALL file, in particular information given below;
387 1.1 mrg * the FAQ (either the FAQ.html file distributed with MPFR, or the
388 1.1.1.5 mrg on-line version <https://www.mpfr.org/faq.html>, which may be more
389 1.1 mrg up-to-date);
390 1.1.1.5 mrg * the MPFR web page for this version <https://www.mpfr.org/mpfr-4.1.0/>,
391 1.1 mrg which lists bugs found in this version and provides some patches.
392 1.1 mrg
393 1.1 mrg If the "configure" fails, please check that the C compiler and its
394 1.1 mrg options are the same as those for the GMP build (specially the ABI).
395 1.1 mrg You can see the latter with the following command:
396 1.1 mrg
397 1.1 mrg grep "^CC\|^CFLAGS" GMPBUILD/Makefile
398 1.1 mrg
399 1.1 mrg if the GMP build directory is available. Then type:
400 1.1 mrg
401 1.1 mrg ./configure <configure options> CC=<C compiler> CFLAGS="<compiler options>"
402 1.1 mrg
403 1.1 mrg (quotes are needed when there are spaces or other special characters
404 1.1 mrg in the CC/CFLAGS value) and continue the install. On some platforms,
405 1.1 mrg you should provide further options to match those used by GMP, or set
406 1.1 mrg some environment variables. For instance, see the "Notes on AIX/PowerPC"
407 1.1 mrg section below.
408 1.1 mrg
409 1.1 mrg Warning! Do NOT use optimization options that can change the semantics
410 1.1 mrg of math operations, such as GCC's -ffast-math or Sun CC's -fast.
411 1.1 mrg Otherwise conversions from/to double's may be incorrect on infinities,
412 1.1 mrg NaN's and signed zeros. Since native FP arithmetic is used in a few
413 1.1 mrg places only, such options would not make MPFR faster anyway.
414 1.1 mrg
415 1.1.1.2 mrg If some "make check" tests fail, you can try the --disable-thread-safe
416 1.1.1.2 mrg configure option (see the configure options above): it has been reported
417 1.1.1.2 mrg that some platforms have buggy TLS support. Before trying this option,
418 1.1.1.2 mrg you may want to check in the configure output whether MPFR was built
419 1.1.1.2 mrg with TLS support; if yes, you will have a line:
420 1.1.1.2 mrg checking for TLS support... yes
421 1.1.1.2 mrg Alternatively "grep MPFR_USE_THREAD_SAFE config.log" will show that
422 1.1.1.2 mrg MPFR_USE_THREAD_SAFE is defined to 1. If it is "no" (or the variable
423 1.1.1.2 mrg is not defined), the --disable-thread-safe option would be useless.
424 1.1.1.2 mrg
425 1.1.1.2 mrg Some tests failure may be due to other compiler bugs, in particular
426 1.1.1.2 mrg in optimization code. You can try to build MPFR without compiler
427 1.1.1.2 mrg optimizations by giving -O0 (letter O, digit 0) in CFLAGS. If the
428 1.1.1.2 mrg MPFR tests no longer fail, this was probably due to a compiler bug,
429 1.1.1.2 mrg though we cannot exclude a bug in MPFR. You may want to contact us
430 1.1.1.2 mrg (see below), possibly after looking at:
431 1.1.1.4 mrg https://members.loria.fr/PZimmermann/software/compilerbugs.html
432 1.1.1.2 mrg
433 1.1 mrg On some platforms, try with "gmake" (GNU make) instead of "make".
434 1.1 mrg Problems have been reported with the Tru64 make.
435 1.1 mrg
436 1.1 mrg If the configure script reports that gmp.h version and libgmp version
437 1.1 mrg are different, or if the build was OK, but the tests failed to link
438 1.1 mrg with GMP or gave an error like
439 1.1 mrg
440 1.1 mrg undefined reference to `__gmp_get_memory_functions'
441 1.1 mrg
442 1.1 mrg meaning that the GMP library was not found or a wrong GMP library was
443 1.1 mrg selected by the linker, then your library search paths are probably
444 1.1 mrg not correctly set (some paths are missing or they are specified in an
445 1.1 mrg incorrect order).
446 1.1 mrg
447 1.1 mrg Such problems commonly occur under some GNU/Linux machines, where the
448 1.1 mrg default header and library search paths may be inconsistent: GCC is
449 1.1 mrg configured to search /usr/local/include and /usr/local/lib by default,
450 1.1 mrg while the dynamic linker ignores /usr/local/lib. If you have a GMP
451 1.1 mrg version installed in /usr (provided by the OS vendor) and a new one
452 1.1 mrg installed in /usr/local, then the header of the new GMP version and
453 1.1 mrg the library of the old GMP version will be used! The best solution
454 1.1 mrg is to make sure that the dynamic linker configuration is consistent
455 1.1 mrg with GCC's behavior, for instance by having /usr/local/lib in
456 1.1 mrg /etc/ld.so.conf or in some file from /etc/ld.so.conf.d (as Debian
457 1.1.1.3 mrg did: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=395177). See
458 1.1.1.5 mrg also https://gcc.gnu.org/legacy-ml/gcc-help/2010-01/msg00171.html for
459 1.1.1.5 mrg more information. Alternatively you can use:
460 1.1 mrg * environment variables. This may sometimes be necessary. If DIR
461 1.1 mrg is the installation directory of GMP, add DIR/include to your
462 1.1 mrg CPATH or C_INCLUDE_PATH (for compilers other than GCC, please
463 1.1 mrg check the manual of your compiler), and add DIR/lib to your
464 1.1 mrg LIBRARY_PATH and LD_LIBRARY_PATH (and/or LD_RUN_PATH);
465 1.1 mrg * --with-gmp* configure options (described above), e.g.
466 1.1 mrg --with-gmp=/opt/local (to use /opt/local/include for headers and
467 1.1 mrg /opt/local/lib for libraries), but other software that uses GMP
468 1.1 mrg and/or MPFR will need correct paths too, and environment variables
469 1.1 mrg allow one to set such search paths in a global way.
470 1.1 mrg Note about "--with-gmp=/usr/local". This option may appear to
471 1.1 mrg solve the above inconsistency problem, but does not work as you
472 1.1 mrg expect. Indeed it affects the library search path, in particular,
473 1.1 mrg the one used by the dynamic linker (thus adding the missing
474 1.1 mrg /usr/local/lib directory as wanted), but since /usr/local/include
475 1.1 mrg is a "standard system include directory" for GCC, the include
476 1.1 mrg search patch is not changed; this is often not a problem in this
477 1.1 mrg particular case because usually, /usr/local/include is already
478 1.1 mrg last in the include search patch, but this may fail under some
479 1.1 mrg occasions and may trigger obscure errors.
480 1.1 mrg
481 1.1 mrg For instance, under Unix, where paths are separated by a colon:
482 1.1 mrg
483 1.1 mrg * With POSIX sh-compatible shells (e.g. sh, ksh, bash, zsh):
484 1.1 mrg export C_INCLUDE_PATH="/usr/local/include:/other/path/include"
485 1.1 mrg export LIBRARY_PATH="/usr/local/lib:/other/path/lib"
486 1.1 mrg export LD_LIBRARY_PATH="$LIBRARY_PATH"
487 1.1 mrg
488 1.1 mrg * With csh or tcsh:
489 1.1 mrg setenv C_INCLUDE_PATH "/usr/local/include:/other/path/include"
490 1.1 mrg setenv LIBRARY_PATH "/usr/local/lib:/other/path/lib"
491 1.1 mrg setenv LD_LIBRARY_PATH "$LIBRARY_PATH"
492 1.1 mrg
493 1.1.1.4 mrg If almost all the tests fail and the messages in the test-suite.log file
494 1.1.1.4 mrg (or in the output, when running individual tests from the command line)
495 1.1.1.4 mrg start with a line of the form:
496 1.1.1.4 mrg
497 1.1.1.4 mrg Incorrect MPFR version! (xxx header vs yyy library)
498 1.1.1.4 mrg
499 1.1.1.4 mrg then this means that an installed MPFR version is tested instead of the
500 1.1.1.4 mrg one that has just been built. This is probably not a bug in MPFR, but a
501 1.1.1.4 mrg problem caused by the user or system configuration (particular options,
502 1.1.1.4 mrg environment variables, etc.) or a bug in the toolchain. In particular,
503 1.1.1.4 mrg if LD_LIBRARY_PATH overrides the run path (set up by libtool) and an
504 1.1.1.4 mrg installed ABI-compatible version of MPFR is in a directory listed in
505 1.1.1.4 mrg the LD_LIBRARY_PATH search path, then this will break. An example with
506 1.1.1.4 mrg GNU ld:
507 1.1.1.4 mrg
508 1.1.1.4 mrg https://sourceware.org/bugzilla/show_bug.cgi?id=21476
509 1.1.1.4 mrg
510 1.1.1.2 mrg If you can't solve your problem, you should contact us via the MPFR
511 1.1.1.2 mrg mailing-list <mpfr (a] inria.fr>, indicating the machine and operating system
512 1.1.1.2 mrg used (uname -a), the compiler and version used (gcc -v if you use gcc),
513 1.1.1.2 mrg the configure options used if any (including variables such as CC and
514 1.1.1.2 mrg CFLAGS), the version of GMP and MPFR used, and a description of the
515 1.1.1.3 mrg problem encountered, in particular the tests/test-suite.log file if
516 1.1.1.3 mrg "make check" failed. Please send us also the log of the "configure"
517 1.1.1.2 mrg (config.log).
518 1.1 mrg
519 1.1 mrg
520 1.1.1.2 mrg Notes about ABI
521 1.1.1.2 mrg ===============
522 1.1.1.2 mrg
523 1.1.1.2 mrg On 64-bit computers, it may happen that the default ABI (Application Binary
524 1.1.1.2 mrg Interface) chosen by MPFR does not correspond to the default one chosen by
525 1.1.1.2 mrg the compiler.
526 1.1.1.2 mrg
527 1.1.1.2 mrg In particular, this kind of message may indicate the problem:
528 1.1.1.2 mrg /usr/bin/ld: skipping incompatible mpfr/src/.libs/libmpfr.a when searching for -lmpfr
529 1.1.1.2 mrg
530 1.1.1.2 mrg In fact, since MPFR relies on GMP, it uses the same ABI as GMP.
531 1.1.1.2 mrg To be sure that your program compiles and links correctly, use the same
532 1.1.1.2 mrg compiler flags as MPFR does (look for CFLAGS in config.log).
533 1.1.1.2 mrg
534 1.1.1.2 mrg You might also recompile GMP with a different ABI, with for example
535 1.1.1.2 mrg ./configure ABI=32.
536 1.1.1.2 mrg
537 1.1.1.2 mrg
538 1.1 mrg Notes on Mac OS X
539 1.1 mrg =================
540 1.1 mrg
541 1.1 mrg If you get an error of the form
542 1.1 mrg
543 1.1 mrg ld: pointer in read-only segment not allowed in slidable image...
544 1.1 mrg
545 1.1 mrg this can mean that the link is done against a static (GMP) library.
546 1.1 mrg In such a case, you should configure MPFR with --disable-shared to
547 1.1 mrg disable the build of the shared library.
548 1.1 mrg
549 1.1 mrg
550 1.1 mrg Notes on FreeBSD 4.3
551 1.1 mrg ====================
552 1.1 mrg
553 1.1 mrg FreeBSD 4.3 is provided with an incorrect <float.h> header file, and
554 1.1 mrg MPFR tests related to long double's may fail. If you cannot upgrade
555 1.1 mrg the system, you can still use MPFR with FreeBSD 4.3, but you should
556 1.1 mrg not use conversions with the long double type.
557 1.1 mrg
558 1.1 mrg
559 1.1 mrg Notes on AIX/PowerPC
560 1.1 mrg ====================
561 1.1 mrg
562 1.1.1.3 mrg The following has been tested on AIX 7.1.3 (gcc111.fsffrance.org)
563 1.1.1.3 mrg with gcc 4.8.1 and GMP 6.1.0.
564 1.1 mrg
565 1.1 mrg If GMP was built with the 64-bit ABI, before building and testing MPFR,
566 1.1 mrg you should set the OBJECT_MODE environment variable to 64, e.g., with:
567 1.1 mrg
568 1.1 mrg export OBJECT_MODE=64
569 1.1 mrg
570 1.1.1.3 mrg (in a sh-compatible shell). Alternatively add the following to the configure
571 1.1.1.3 mrg line: AR="ar -X64" NM="nm -B -X64".
572 1.1 mrg
573 1.1 mrg
574 1.1.1.4 mrg Notes on Solaris
575 1.1.1.4 mrg ================
576 1.1.1.4 mrg
577 1.1.1.4 mrg Do not put a -R<dir> option in the LD_OPTIONS environment variable, at least
578 1.1.1.4 mrg if the directory <dir> can contain an MPFR library. Otherwise this MPFR
579 1.1.1.4 mrg library may be chosen for the tests (make check) instead of the one that has
580 1.1.1.4 mrg just been built, in which case, either you will get errors due to unmatched
581 1.1.1.4 mrg versions or this problem may remain undetected. The reason is that this
582 1.1.1.4 mrg option will appear before the -R options added by libtool, such as the one
583 1.1.1.4 mrg to the src/.libs directory containing the MPFR library that has just been
584 1.1.1.4 mrg built, and will have the precedence.
585 1.1.1.4 mrg
586 1.1.1.4 mrg
587 1.1.1.3 mrg MPFR for use with Windows Applications
588 1.1.1.3 mrg ======================================
589 1.1.1.2 mrg
590 1.1.1.2 mrg There are several ways of building MPFR on Windows, the most appropriate
591 1.1.1.2 mrg approach depending on how you intend to use the resulting libraries.
592 1.1.1.2 mrg
593 1.1.1.2 mrg a. Using MinGW
594 1.1.1.2 mrg ==============
595 1.1 mrg
596 1.1.1.3 mrg 1 - We advise to use MinGW (http://www.mingw.org/ for 32-bit, and
597 1.1.1.3 mrg https://sourceforge.net/projects/mingw-w64/ for 32- and 64-bit),
598 1.1.1.3 mrg which is simpler and less demanding than Cygwin. Contrary to Cygwin,
599 1.1.1.3 mrg it also provides native Windows code.
600 1.1 mrg
601 1.1.1.4 mrg If you also use MSYS, you should use "make" for MSYS instead of
602 1.1.1.4 mrg the "make" utility from MinGW-W64 or from GCC, which causes the
603 1.1.1.4 mrg following error:
604 1.1.1.4 mrg
605 1.1.1.4 mrg libtool: warning: libobj name 'extract.Tpo -c -o extract.lo extract.lo'
606 1.1.1.4 mrg may not contain shell special characters.
607 1.1.1.4 mrg rm: unknown option -- c
608 1.1.1.4 mrg
609 1.1.1.4 mrg References about this issue and solution:
610 1.1.1.4 mrg https://sourceforge.net/p/msys2/tickets/223/
611 1.1.1.4 mrg https://sympa.inria.fr/sympa/arc/mpfr/2016-07/msg00009.html
612 1.1.1.4 mrg
613 1.1 mrg 2 - If you just want to make a binary with gcc, there is nothing to do:
614 1.1.1.4 mrg GMP, MPFR and the program compile exactly as under Linux. (It is
615 1.1.1.4 mrg recommended to pass --build=xxx-yyy-mingw64 to the GMP configure command,
616 1.1.1.4 mrg or --build=xxx with xxx containing mingw.)
617 1.1 mrg
618 1.1.1.3 mrg 3 - To avoid using the Microsoft runtime (which might not be conform to ISO C),
619 1.1 mrg you can use the MinGW runtime package (which is an integral part of MinGW).
620 1.1.1.4 mrg
621 1.1.1.5 mrg With old MinGW versions, you can get an ISO-compliant printf()
622 1.1.1.5 mrg if you compile your application with either '-ansi', '-posix' or
623 1.1.1.5 mrg '-D__USE_MINGW_ANSI_STDIO'. But note that this latter option,
624 1.1.1.5 mrg which was useful in the past (see below) should no longer be used.
625 1.1.1.5 mrg
626 1.1.1.5 mrg The following applies to old MinGW versions, and may be discouraged
627 1.1.1.5 mrg with recent MinGW versions.
628 1.1.1.5 mrg
629 1.1.1.5 mrg In order to have the MPFR formatted output functions based on an
630 1.1.1.5 mrg ISO-compliant printf(), you need to compile GMP (not MPFR) with
631 1.1.1.5 mrg CC="gcc -D__USE_MINGW_ANSI_STDIO" (since the standard printf modifiers
632 1.1.1.5 mrg %e, %Ld and %td are passed to GMP).
633 1.1.1.5 mrg
634 1.1.1.5 mrg To avoid failures of some of the printf-related tests, MPFR needs to
635 1.1.1.5 mrg be compiled with the same __USE_MINGW_ANSI_STDIO as with GMP, i.e.
636 1.1.1.5 mrg this macro should be defined for both or undefined for both; this
637 1.1.1.5 mrg should be the case by default, unless CC or CFLAGS has been redefined.
638 1.1.1.5 mrg For instance, if __USE_MINGW_ANSI_STDIO is defined in GMP but not in
639 1.1.1.5 mrg MPFR, the following error may occur:
640 1.1.1.4 mrg
641 1.1.1.4 mrg Error in mpfr_vsprintf (s, "%e", ...);
642 1.1.1.4 mrg expected: "-1.250000e+000"
643 1.1.1.4 mrg got: "-1.250000e+00"
644 1.1.1.4 mrg FAIL tsprintf.exe (exit status: 1)
645 1.1.1.4 mrg
646 1.1.1.5 mrg and in the opposite case:
647 1.1.1.5 mrg
648 1.1.1.5 mrg Error in mpfr_vsprintf (s, "%e", ...);
649 1.1.1.5 mrg expected: "-1.250000e+00"
650 1.1.1.5 mrg got: "-1.250000e+000"
651 1.1.1.5 mrg FAIL tsprintf.exe (exit status: 1)
652 1.1.1.5 mrg
653 1.1.1.5 mrg Note with old GMP versions: Other issues could arise due to the fact
654 1.1.1.5 mrg that the C functions vsnprintf and vsprintf both used internally in
655 1.1.1.5 mrg old GMP versions do not produce the same output:
656 1.1.1.4 mrg
657 1.1.1.4 mrg https://sympa.inria.fr/sympa/arc/mpfr/2016-03/msg00045.html
658 1.1.1.4 mrg https://sympa.inria.fr/sympa/arc/mpfr/2016-03/msg00051.html
659 1.1.1.4 mrg https://sympa.inria.fr/sympa/arc/mpfr/2016-03/msg00053.html
660 1.1.1.4 mrg
661 1.1.1.5 mrg If __USE_MINGW_ANSI_STDIO has not been defined when building GMP,
662 1.1.1.5 mrg then the length modifiers j, L and t are not supported with the GMP
663 1.1.1.5 mrg formatted output functions, and as a consequence, also with MPFR.
664 1.1.1.5 mrg This is automatically detected by the configure script, except when
665 1.1.1.5 mrg cross-compiling (e.g. under Linux), in which case some macros need
666 1.1.1.5 mrg to be defined explicitly, e.g. with
667 1.1.1.5 mrg
668 1.1.1.5 mrg "CPPFLAGS=-DNPRINTF_J -DNPRINTF_L -DNPRINTF_T"
669 1.1.1.5 mrg
670 1.1.1.5 mrg in order to avoid potential issues with the MPFR library and failures
671 1.1.1.5 mrg in the test suite (the corresponding tests are disabled explicitly).
672 1.1.1.2 mrg
673 1.1.1.2 mrg b. Using Cygwin
674 1.1.1.2 mrg ===============
675 1.1.1.2 mrg
676 1.1.1.2 mrg This build should be similar to that for MinGW except that the resulting
677 1.1.1.2 mrg library depends on the Cygwin DLL and cannot therefore be used with
678 1.1.1.2 mrg Visual Studio as with MinGW. Indeed, the binaries compiled with Cygwin
679 1.1.1.2 mrg require a dynamic library (cygwin.dll) to work; there is a Cygwin option
680 1.1.1.2 mrg -mno-cygwin to build native code, but it may require some non-portable tricks.
681 1.1.1.2 mrg
682 1.1.1.2 mrg In case of failure, you may need to pass LDFLAGS='-shared-libgcc' at the
683 1.1.1.2 mrg end of the configure line due to a bug in GCC. Otherwise, if threading
684 1.1.1.2 mrg support is not needed, you can configure MPFR with --disable-thread-safe.
685 1.1.1.2 mrg
686 1.1.1.3 mrg c. Using Microsoft Visual C++ and Intel C++ Compilers
687 1.1.1.3 mrg =====================================================
688 1.1.1.2 mrg
689 1.1.1.3 mrg Static and dynamic MPFR libraries for the 32- and 64-bit versions of
690 1.1.1.3 mrg Windows can be built with Microsoft Visual Studio 2015 using the
691 1.1.1.3 mrg Microsoft Visual C++ compiler, see:
692 1.1.1.2 mrg
693 1.1.1.5 mrg https://visualstudio.microsoft.com/
694 1.1.1.2 mrg
695 1.1.1.3 mrg The Intel C++ compiler provided as a part of Intel Parallel Studio XE
696 1.1.1.3 mrg can also be used:
697 1.1 mrg
698 1.1.1.5 mrg https://software.intel.com/en-us/parallel-studio-xe
699 1.1 mrg
700 1.1.1.3 mrg The relevant build projects are available here:
701 1.1 mrg
702 1.1.1.3 mrg https://github.com/BrianGladman
703 1.1.1.5 mrg
704 1.1.1.5 mrg d. Using the CompCert compiler
705 1.1.1.5 mrg ==============================
706 1.1.1.5 mrg
707 1.1.1.5 mrg [this was tested with CompCert 3.7 and MPFR revision 13851 on x86_64-linux]
708 1.1.1.5 mrg
709 1.1.1.5 mrg CompCert (http://compcert.inria.fr/) is a formally verified compiler.
710 1.1.1.5 mrg To compile MPFR with CompCert:
711 1.1.1.5 mrg
712 1.1.1.5 mrg $ ./configure CC=ccomp CFLAGS="-fbitfields -flongdouble -fstruct-passing" --disable-shared
713 1.1.1.5 mrg
714 1.1.1.5 mrg You also need to unset LD_LIBRARY_PATH, and/or you might need to change
715 1.1.1.5 mrg wl="" into wl="-Wl," in the libtool file.
716 1.1.1.5 mrg
717 1.1.1.5 mrg All tests (make check) should pass (tget_set_d64, tget_set_d128 and
718 1.1.1.5 mrg tset_float128 are skipped, since CompCert does not support _Decimal64,
719 1.1.1.5 mrg _Decimal128 nor _Float128).
720