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