source: git/ntl/doc/tour-unix.html @ de6a29

spielwiese
Last change on this file since de6a29 was de6a29, checked in by Hans Schönemann <hannes@…>, 18 years ago
* hannes: NTL-5.4 git-svn-id: file:///usr/local/Singular/svn/trunk@8693 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 11.1 KB
Line 
1<html>
2<head>
3<title>
4A Tour of NTL: Obtaining and Installing NTL for UNIX  </title>
5</head>
6
7<body bgcolor="#fff9e6">
8<center>
9<a href="tour-stdcxx.html"><img src="arrow1.gif" alt="[Previous]" align=bottom></a>
10 <a href="tour.html"><img src="arrow2.gif" alt="[Up]" align=bottom></a> 
11<a href="tour-win.html"> <img src="arrow3.gif" alt="[Next]" align=bottom></a>
12</center>
13
14<h1> 
15<p align=center>
16A Tour of NTL: Obtaining and Installing NTL for UNIX
17</p>
18</h1>
19
20<p> <hr> <p>
21
22This procedure should work on most Unix or Unix-like platorms
23(including MAC OSX, and Windows with Cygwin tools).
24
25<p>
26
27
28To obtain the source code and documentation for NTL,
29<a href="http://www.shoup.net/ntl/download.html">
30download <tt>ntl-xxx.tar.gz</tt></a>,
31placing it a directory, and then, working in this directory,
32do the following.
33Here, "<tt>xxx</tt>" denotes the current version number.
34
35
36
37<p>
38<pre>
39   % gunzip ntl-xxx.tar.gz
40   % tar xf ntl-xxx.tar
41   % cd ntl-xxx/src
42   % ./configure PREFIX=$HOME/sw
43   % make
44   % make check
45   % make install
46</pre>
47
48This will build, test, and install NTL in <tt>$HOME/sw</tt>.
49Of course, change <tt>$HOME/sw</tt> to whatever you want (the default is
50<tt>/usr/local</tt>).
51You will find the NTL header files in <tt>$HOME/sw/include/NTL</tt>
52 and the compiled binary
53in <tt>$HOME/sw/lib/libntl.a</tt>.
54<p>
55If you really are interested in high-performace, you will
56<i>definitely</i> want to build NTL
57using  GMP (the GNU Multi-Precision package).
58If GMP has already been installed in a standard
59system library, like <tt>/usr/local</tt>, then invoke <tt>configure</tt>
60above as
61<pre>
62   % ./configure PREFIX=$HOME/sw NTL_GMP_LIP=on
63</pre>
64and if GMP is installed somewhere else, say <tt>$HOME/sw</tt>, then
65<pre>
66   % ./configure PREFIX=$HOME/sw NTL_GMP_LIP=on GMP_PREFIX=$HOME/sw
67</pre>
68does the job.
69<a href="tour-gmp.html">This page</a> provides more
70details.
71
72
73<p>
74Now suppose you want to compile a program that uses NTL.
75Suppose you are working in some directory and <tt>foo.c</tt>
76is your program.
77Assume that you have installed NTL in <tt>$HOME/sw</tt> as above.
78The following should work:
79<pre>
80   % g++ -I$HOME/sw/include -L$HOME/sw/lib foo.c -o foo -lntl -lm
81</pre>
82If you are using GMP, then:
83<pre>
84   % g++ -I$HOME/sw/include -L$HOME/sw/lib foo.c -o foo -lntl -lgmp -lm
85</pre>
86
87<p>
88<h2>
89More Details
90</h2>
91<p>
92What follows is a more detailed description of the installation process.
93
94
95
96
97<p>
98<b>Step 1.</b>
99Extract the source files by executing:
100<pre>
101   % gunzip ntl-xxx.tar.gz
102   % tar xvf ntl-xxx.tar
103</pre>
104
105<p>
106Note that this will unpack everything into a sub-directory <tt>ntl-xxx</tt>,
107creating this directory if necessary.
108Next:
109<pre>
110   % cd ntl-xxx
111   % ls
112</pre>
113You should see a file "<tt>README</tt>", and directories
114"<tt>include</tt>", "<tt>doc</tt>", and "<tt>src</tt>".
115The directory "<tt>doc</tt>" contains all the documentation.
116The file "<tt>doc/tour.html</tt>" contains a copy of the on-line documentation.
117The directory "<tt>include</tt>"
118contains all the header files within a subdirectory
119"<tt>include/NTL</tt>".
120The directory "<tt>src</tt>" contains everything else.
121Go there now:
122<pre>
123   % cd src
124</pre>
125
126<p>
127<b>Step 2.</b>
128Run the configuration script.
129
130<p>
131Execute the command
132<pre>
133   % ./configure [ variable=value ]...
134</pre>
135
136This configure script generates the file "<tt>makefile</tt>" and the file
137"<tt>../include/NTL/config.h</tt>", based upon the values assigned to the
138variables on the command line.
139
140
141<p>
142
143Here are the most important variables, and their default values.
144
145<p>
146<pre>
147   CC=gcc               # The C compiler
148   CXX=g++              # The C++ compiler
149   CFLAGS=-O2           # C complilation flags
150   CXXFLAGS=$(CFLAGS)   # C++ compilation flags (by default, same as CFLAGS)
151
152   PREFIX=/usr/local    # Directory in which to install NTL library components
153
154   NTL_STD_CXX=on       # ISO Mode switch
155
156   NTL_GMP_LIP=off      # Switch 'on' to enable the use of GMP as the primary
157                        # long integer package
158
159   GMP_PREFIX=none      # Directory in which GMP components have been installed
160</pre>
161
162<p>
163<i>Examples.</i>
164<p>
165
166<ul>
167<li>
168If you are happy with all the default values, run:
169<pre>
170   % ./configure
171</pre>
172Actually, the initially installed <tt>makefile</tt> and <tt>config.h</tt> files
173already reflect the default values, and you do not have to even run
174the configure script.
175
176<p>
177<li>
178If your C/C++ compilers are called cc/CC, run:
179<pre>
180   % ./configure CC=cc CXX=CC
181</pre>
182
183<p>
184<li>
185If you want to use, say, the options <tt>-g</tt> and <tt>-O</tt> for
186compiling <tt>C</tt> and <tt>C++</tt>, run:
187<pre>
188   % ./configure "CFLAGS=-g -O"
189</pre>
190Note the use of quotes to keep the argument in one piece.
191
192<p>
193<li>
194If <a href="tour-gmp.html">GMP (the GNU Multi-Precision package)</a> 
195is installed in a standard system directory, and you want to use it
196to obtain better performance for long integer arithemtic, run:
197<pre>
198   % ./configure NTL_GMP_LIP=on
199</pre>
200If GMP was installed in
201 <tt>$HOME/sw</tt>,
202run:
203<pre>
204   % ./configure NTL_GMP_LIP=on GMP_PREFIX=$HOME/sw
205</pre>
206Go <a href="tour-gmp.html">here</a> for complete details.
207
208<p>
209<li>
210If you want to use
211<a href="tour-stdcxx.html">traditional rather than ISO mode</a>, run:
212<pre>
213   % ./configure NTL_STD_CXX=off
214</pre>
215
216<p>
217<li>
218If you want to install NTL in the directory <tt>$HOME/sw</tt>,
219run:
220<pre>
221   % ./configure PREFIX=$HOME/sw
222</pre>
223</ul>
224
225<p>
226There are a number of more esoteric configuration variables that can be set.
227See <a href="config.txt"><tt>config.txt</tt></a> for a complete
228description.
229
230<p>
231Note that all of these configuration options can also be set
232by editing the two files <tt>makefile</tt>
233and <tt>../include/NTL/def_config.h</tt> by hand.
234These files are fairly simple and well documented, and so this is not
235too hard to do.
236
237<p>
238Note that the file "<tt>../include/NTL/def_config.h</tt>"
239contains a backup copy of the original <tt>config.h</tt> file,
240and that the file "<tt>def_makefile</tt>"
241contains a backup copy of the original <tt>makefile</tt> file.
242
243<p>
244This command is intended only as a convenience
245and -- more importantly -- to allow the configuration process
246to be script driven.
247This script does not perform any "magic", like finding out what
248the local C compiler is called, etc. 
249If the defaults are not
250correct for your platform, you have to set an appropriate variable.
251
252
253
254<p>
255<b>Step 3.</b>
256Execute <tt>make</tt>.
257
258<p>
259Just type:
260<pre>
261   % make
262</pre>
263
264<p>
265The build  process after this point is fully automatic.
266But here is a description of what happens.
267
268<p>
269
270<ol>
271<li>
272The makefile
273builds the file "<tt>../include/NTL/mach_desc.h</tt>", which defines some machine characteristics
274such as word size and machine precision.
275This is done by compiling and running a <tt>C</tt> program
276called <tt>MakeDesc</tt>
277that figures out these characteristics on its
278own, and prints some diagnostics to the terminal.
279
280<p>
281<li>
282A script is run that "automagically"
283determines the best way to write a timing function
284on your platform.
285It tries different routines in the files <tt>GetTime1.c</tt>,
286<tt>GetTime2.c</tt>, etc., and when it finds a good one,
287it copies the file into <tt>GetTime.c</tt>.
288
289<p>
290<li>
291The files "<tt>lip_gmp_aux_impl.h</tt>" and "<tt>../include/NTL/gmp_aux.h</tt>"
292are generated for use with GMP.
293If not using GMP, these files are still created, but they are empty.
294
295
296<p>
297<li>
298The configuration wizard script is run.
299This script works in a sub-directory,
300compiling several programs,
301and performing a number of timing experiments,
302in order to determine the optimal setting for a number of flags
303in the file <tt>../include/NTL/config.h</tt>.
304When the script finishes (it may take several minutes),
305you will be told what the wizard thinks are the best settings,
306and your <tt>config.h</tt> file will be automatically updated.
307Note that any flags you set in Step 2
308will be in
309effect while the wizard runs, and will be retained in the updated
310<tt>config.h</tt> file, with the exception of the flags
311<pre>
312   NTL_LONG_LONG NTL_AVOID_FLOAT NTL_TBL_REM NTL_AVOID_BRANCHING
313   NTL_SPMM_UL NTL_SPMM_ULL NTL_SPMM_ASM NTL_GF2X_NOINLINE NTL_GF2X_ALTCODE
314</pre>
315which are set by the wizard.
316Also note that if you <i>do not</i> want the wizard to run,
317you should pass <tt>WIZARD=off</tt> to the configure script;
318however, this is not recommended.
319
320<p>
321<li>
322The makefile will compile all the source files,
323and then creates the library "<tt>ntl.a</tt>" in the current directory.
324</ol>
325
326<p>
327Note that for finer control  you can optionally  break up this process
328into the five
329component steps:
330<pre>
331   % make setup1
332   % make setup2
333   % make setup3
334   % make setup4
335   % make ntl.a
336</pre>
337
338
339<p>
340
341<p>
342<b>After NTL is built.</b>
343
344<p>
345Executing <tt>make check</tt> runs a series of timing and test programs.
346It is a good idea to run this to see if everything really
347went well.
348
349<p>
350Executing <tt>make install</tt>
351copies a number of files to a directory <tt>&lt;prefix&gt;</tt> that you
352specify by passing <tt>PREFIX=&lt;prefix&gt;</tt>
353as an argument to <tt>configure</tt> at configuration time,
354or as an argument to <tt>make install</tt> at installation time.
355The default is <tt>/usr/local</tt>, so either you need root
356permissions, or you choose a <tt>&lt;prefix&gt;</tt> for which
357you have write permission.
358The files <tt>../include/NTL/*</tt> are copied into
359<tt>&lt;prefix&gt;/include/NTL</tt>.
360The file <tt>ntl.a</tt> is copied to <tt>&lt;prefix&gt;/lib/libntl.a</tt>.
361The files <tt>../doc/*</tt> are copied into
362<tt>&lt;prefix&gt;/doc/NTL</tt>.
363
364<p>
365You can also "fine tune" the installation procedure further.
366See the <a href="config.txt">configure documentation</a> for details.
367
368<p>
369Executing <tt>make uninstall</tt> undoes <tt>make install</tt>.
370
371
372<p>
373Executing <tt>make clobber</tt> essentially
374undoes <tt>make</tt>.
375<i>Make sure you do this if you re-build NTL for a different architecture!</i>
376
377<p>
378Executing <tt>make clean</tt> will remove object files, but not
379<tt>ntl.a</tt>.
380To rebuild after executing <tt>make clean</tt>, execute <tt>make ntl.a</tt>.
381
382
383<p>
384Assuming you have installed NTL as above,
385to compile a program <tt>foo.c</tt> that uses NTL,
386execute
387<pre>
388   g++ -I&lt;prefix&gt;/include -L&lt;prefix&gt;/lib foo.c -o foo -lntl -lm
389</pre>
390This compiles <tt>foo.c</tt> as a <tt>C++</tt> program
391and creates the binary <tt>foo</tt>.
392<p>
393If you built NTL using <a href="tour-gmp.html">GMP</a>, execute:
394<pre>
395   g++ -I&lt;prefix&gt;/include -L&lt;prefix&gt;/lib -L&lt;gmp_prefix&gt;/lib  foo.c -lntl -lgmp -lm
396</pre>
397<p>
398Of course, if <tt>&lt;prefix&gt;</tt> and <tt>&lt;gmp_prefix&gt;</tt>
399are the same, you do not need to  duplicate the <tt>-L</tt> 
400flags, and if either are standard directories, like <tt>/usr/local</tt>,
401you can leave out the corresponding <tt>-I</tt> and <tt>-L</tt>
402flags altogether.
403<p>
404This works even if you are not working in the directory
405in which you built NTL.
406If you <i>are</i> working in that directory, you can just execute
407<pre>
408   make foo
409</pre>
410
411
412<p> <p>
413<p> <p>
414
415<center>
416<a href="tour-stdcxx.html"><img src="arrow1.gif" alt="[Previous]" align=bottom></a>
417 <a href="tour.html"><img src="arrow2.gif" alt="[Up]" align=bottom></a> 
418<a href="tour-win.html"> <img src="arrow3.gif" alt="[Next]" align=bottom></a>
419</center>
420
421</body>
422</html>
Note: See TracBrowser for help on using the repository browser.