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