[BACK]Return to INSTALL CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gmp

Annotation of OpenXM_contrib/gmp/INSTALL, Revision 1.1.1.1

1.1       maekawa     1: INSTALLING GMP
                      2: ==============
                      3:
                      4: These instructions are only for the impatient.  Others should read the install
                      5: instructions in the manual, gmp.info.  Use "info -f gmp.info", or, if you
                      6: don't have info, use type "C-h i g (gmp.info)Top" in emacs.
                      7:
                      8: Here are short instructions how to install MP, and some examples that help you
                      9: get started using MP.
                     10:
                     11: First, you need to compile, and optionally install, MP.  Since you're
                     12: impatient, try this:
                     13:
                     14:        ./configure; make
                     15:
                     16: If that fails, or you care about the performance of MP, you need to read the
                     17: full instructions in the chapter "Installing MP", in the manual.
                     18:
                     19: Next, you need to try some small test programs, for example the ones below.
                     20:
                     21: In MP programs, all variables need to be initialized before they are assigned,
                     22: and cleared out before program flow leaves the scope in which it was declared.
                     23: Here is an example of a program that reads two numbers from the command line,
                     24: multiplies them, and prints the result to stdout.
                     25:
                     26:     #include <stdio.h>
                     27:     #include <gmp.h>         /* All MP programs need to include gmp.h */
                     28:
                     29:     main (int argc, char **argv)
                     30:     {
                     31:       mpz_t a, b, p;
                     32:
                     33:       /* Initialize variables */
                     34:       mpz_init (a);
                     35:       mpz_init (b);
                     36:       mpz_init (p);
                     37:
                     38:       /* Assign a and b from base 10 strings in argv */
                     39:       mpz_set_str (a, argv[1], 10);
                     40:       mpz_set_str (b, argv[2], 10);
                     41:
                     42:       /* Multiply a and b and put the result in p */
                     43:       mpz_mul (p, a, b);
                     44:
                     45:       /* Print p in base 10 */
                     46:       mpz_out_str (stdout, 10, p);
                     47:       fputc ('\n', stdout);
                     48:
                     49:       /* Clear out variables */
                     50:       mpz_clear (a);
                     51:       mpz_clear (b);
                     52:       mpz_clear (p);
                     53:       exit (0);
                     54:     }
                     55:
                     56:
                     57: In practice, that example would be written like this instead:
                     58:
                     59:     #include <stdio.h>
                     60:     #include <gmp.h>
                     61:
                     62:     main (int argc, char **argv)
                     63:     {
                     64:       mpz_t a, b, p;
                     65:
                     66:       /* Initialize and assign a and b from base 10 strings in argv */
                     67:       mpz_init_set_str (a, argv[1], 10);
                     68:       mpz_init_set_str (b, argv[2], 10);
                     69:       /* Initialize p */
                     70:       mpz_init (p);
                     71:
                     72:       /* Multiply a and b and put the result in p */
                     73:       mpz_mul (p, a, b);
                     74:
                     75:       /* Print p in base 10 */
                     76:       mpz_out_str (stdout, 10, p);
                     77:       fputc ('\n', stdout);
                     78:
                     79:       /* Since we're about to exit, no need to clear out variables */
                     80:       exit (0);
                     81:     }
                     82:
                     83: Finally, you have to compile your test program, and link it with the MP
                     84: library.  Assuming your working directory is still the gmp source directory,
                     85: type:
                     86:
                     87:        gcc -g -I. example.c libgmp.a
                     88:
                     89:
                     90: Now try to run the example:
                     91:
                     92:        a.out 98365871231256752134 319378318340103345227
                     93:        31415926535897932384618573336104570964418
                     94:
                     95: The functions used here all operate on the domain of signed integers.
                     96: Functions operating on that domain have names starting with "mpz_".  There are
                     97: many more such functions than used in these examples.  See the chapter
                     98: "Integer Functions" in the manual, for a complete list.
                     99:
                    100: There are two other main classes of functions in MP.  They operate on rational
                    101: numbers and floating-point numbers, respectively.  The chapters "Rational
                    102: Number Functions", and "Floating-point Functions" documents these classes.
                    103:
                    104: To run a set of tests, do "make check".  This will take a while.
                    105:
                    106: To create the printable documentation from the texinfo source, type "make
                    107: dvi".  This requires the "tex" command to be available in your search path.
                    108:
                    109: To install the library, do "make install".
                    110:
                    111: If you decide to use MP, It is a good idea you read at least the chapter "MP
                    112: Basics" in the manual.
                    113:
                    114:
                    115: Known Build Problems
                    116: --------------------
                    117:
                    118: Note that GCC 2.7.2 (as well as 2.6.3) for the RS/6000 and PowerPC can not
                    119: be used to compile GMP, due to a bug in GCC.  If you want to use GCC, you
                    120: need to apply the patch at the end of this file, or use a later version of
                    121: the compiler.
                    122:
                    123: If you are on a Sequent Symmetry, use GAS instead of the system's assembler
                    124: due to the latter's serious bugs.
                    125:
                    126: The system compiler on NeXT is a massacred and old gcc, even if the
                    127: compiler calls itself cc.  This compiler cannot be used to build GMP.  You
                    128: need to get a real gcc, and install that before you compile GMP.  (NeXT
                    129: might have fixed this in newer releases of their system.)
                    130:
                    131: Please report other problems to bug-gmp@prep.ai.mit.edu.
                    132:
                    133:
                    134: Patch to apply to GCC 2.6.3 and 2.7.2:
                    135:
                    136: *** config/rs6000/rs6000.md    Sun Feb 11 08:22:11 1996
                    137: --- config/rs6000/rs6000.md.new        Sun Feb 18 03:33:37 1996
                    138: ***************
                    139: *** 920,926 ****
                    140:      (set (match_operand:SI 0 "gpc_reg_operand" "=r")
                    141:        (not:SI (match_dup 1)))]
                    142:     ""
                    143: !   "nor. %0,%2,%1"
                    144:     [(set_attr "type" "compare")])
                    145:
                    146:   (define_insn ""
                    147: --- 920,926 ----
                    148:      (set (match_operand:SI 0 "gpc_reg_operand" "=r")
                    149:        (not:SI (match_dup 1)))]
                    150:     ""
                    151: !   "nor. %0,%1,%1"
                    152:     [(set_attr "type" "compare")])
                    153:
                    154:   (define_insn ""

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>