This file is indexed.

/usr/share/doc/libntl-dev/NTL/tour-unix.html is in libntl-dev 9.9.1-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
<html>
<head>
<title>
A Tour of NTL: Obtaining and Installing NTL for UNIX  </title>
</head>

<center>
<a href="tour-modules.html"><img src="arrow1.gif" alt="[Previous]" align=bottom></a>
 <a href="tour.html"><img src="arrow2.gif" alt="[Up]" align=bottom></a> 
<a href="tour-win.html"> <img src="arrow3.gif" alt="[Next]" align=bottom></a>
</center>

<h1> 
<p align=center>
A Tour of NTL: Obtaining and Installing NTL for UNIX 
</p>
</h1>

<p> <hr> <p>

This procedure should work on most Unix or Unix-like platorms
(including Mac OSX, and Windows with MinGW or Cygwin tools).

<p>


To obtain the source code and documentation for NTL,
<a href="http://www.shoup.net/ntl/download.html">
download <tt>ntl-xxx.tar.gz</tt></a>,
placing it a directory, and then, working in this directory,
do the following.
Here, "<tt>xxx</tt>" denotes the current version number.



<p>
<pre>
   % gunzip ntl-xxx.tar.gz
   % tar xf ntl-xxx.tar
   % cd ntl-xxx/src
   % ./configure 
   % make
   % make check
   % make install
</pre>

This will build, test, and install NTL in 
<tt>/usr/local</tt>.
For this to work, GMP must already be installed
(most Unix distributions already come with GMP installed,
but see <a href="tour-gmp.html">this page</a> for more
details).
If you really do not want to use GMP,
you can pass the option
<tt>NTL_GMP_LIP=off</tt> 
to <tt>configure</tt>.

<p>
After installation,
you will find the NTL header files in <tt>/usr/local/include/NTL</tt>
 and the compiled binary 
in <tt>/usr/local/lib/libntl.a</tt>
(this is a <i>static</i> library -- if you want a <i>shared</i>
library, <a href="#shared">see below</a>).
Documentation is in <tt>/usr/local/share/doc</tt>,
with the main entry-point at <tt>/usr/local/share/doc/tour.html</tt>.



<p>
If you want very high-performance for polynomial arithmetic
over <i>GF(2)</i>, you may want to consider using the <tt>gf2x</tt> library.
To do this, <tt>gf2x</tt> must already be installed.
In addition, you should invoke <tt>configure</tt>
with the option <tt>NTL_GF2X_LIB=on</tt>.
<a href="tour-gf2x.html">This page</a> provides more details.

 

<p>
If you want to install NTL install NTL somewhere besides <tt>/usr/local</tt>,
pass the option <tt>PREFIX=/path/to/install/ntl</tt> to 
<tt>configure</tt>.
If GMP is installed somewhere besides <tt>/usr/local</tt>,
pass the optopn 
<tt>GMP_PREFIX=/path/to/gmp</tt> 
to <tt>configure</tt>.
You can also pass
<tt>GF2X_PREFIX=/path/to/gf2x</tt> 
to <tt>configure</tt>,
if <tt>gf2x</tt> is installed somewhere besides <tt>/usr/local</tt>.
As a shorthand, you pass the option 
<tt>DEF_PREFIX=/path/to/all/software</tt>, which will
override the default for <tt>PREFIX</tt>,
<tt>GMP_PREFIX</tt>, and <tt>GF2X_PREFIX</tt>.



<p>
Now suppose you want to compile a program that uses NTL.
Suppose you are working in some arbitrary directory and <tt>foo.c</tt>
is your program.
Assume that you have installed NTL in <tt>/usr/local</tt> as above.
The following should work:
<pre>
   % g++ -g -O2 foo.c -o foo -lntl -lgmp -lm
</pre>
If you have installed NTL and/or GMP is a non-standard location,
say <tt>/path/to/sw</tt>,
then:
<pre>
   % g++ -g -O2 -I/path/to/sw/include foo.c -o foo  -L/path/to/sw/lib -lntl -lgmp -lm
</pre>
If you build NTL with <tt>gf2x</tt>, just add the option
<tt>-lgf2x</tt> to the above, right after <tt>-lgmp</tt>.

<p>
If you are working in the NTL <tt>src</tt> directory itself,
you can just run:
<pre>
   % make foo
</pre>
to compile a program <tt>foo.c</tt>, as above.

<p>
<h2>
More Details
</h2>
<p>
What follows is a more detailed description of the installation process.




<p>
<b>Step 1.</b>
Extract the source files by executing:
<pre>
   % gunzip ntl-xxx.tar.gz
   % tar xvf ntl-xxx.tar
</pre>

On most systems, the following shortcut works:
<pre>
   % tar xzvf ntl-xxx.tar.gz
</pre>

<p>
Note that this will unpack everything into a sub-directory <tt>ntl-xxx</tt>,
creating this directory if necessary.
Next:
<pre>
   % cd ntl-xxx
   % ls
</pre>
You should see a file "<tt>README</tt>", and directories 
"<tt>include</tt>", "<tt>doc</tt>", and "<tt>src</tt>".
The directory "<tt>doc</tt>" contains all the documentation.
The file "<tt>doc/tour.html</tt>" contains a copy of the on-line documentation.
The directory "<tt>include</tt>" 
contains all the header files within a subdirectory
"<tt>include/NTL</tt>".
The directory "<tt>src</tt>" contains everything else.
Go there now:
<pre>
   % cd src
</pre>

<p>
<b>Step 2.</b>
Run the configuration script.

<p>
Execute the command
<pre>
   % ./configure [ variable=value ]...
</pre>

This configure script generates the file "<tt>makefile</tt>" and the file
"<tt>../include/NTL/config.h</tt>", based upon the values assigned to the
variables on the command line.


<p>

Here are the most important variables, and their default values.

<p>
<pre>

CXX=g++              # The C++ compiler

CXXFLAGS=-g -O2      # C++ complilation flags

NATIVE=on            # Compiles code targeted to the current hardware

DEF_PREFIX=/usr/local# Default software directory

PREFIX=$(DEF_PREFIX) # Directory in which to install NTL library components
SHARED=off           # Generate a shared library (as well as static)

NTL_THREADS=off      # compile in thread-safe mode
NTL_THREAD_BOOST=off # compile with thread boosting enabled
NTL_EXCEPTIONS=off   # compile with exceptions enabled

NTL_GMP_LIP=on       # Switch to enable the use of GMP as primary 
                     #   long integer package

GMP_PREFIX=$(DEF_PREFIX) # Directory in which GMP components are installed

NTL_GF2X_LIB=off     # Switch to enable the use of the gf2x package
                     #   for faster arithmetic GF(2)[X]

GF2X_PREFIX=$(DEF_PREFIX) # Directory in which gf2x components are installed


</pre>

<p>
<i>Examples.</i>
<p>

<ul>
<li>
If you are happy with all the default values, run:
<pre>
   % ./configure
</pre>
Actually, the initially installed <tt>makefile</tt> and <tt>config.h</tt> files
already reflect the default values, and you do not have to even run
the configure script.

<p>
<li>
If your C++ compilers is called CC, run:
<pre>
   % ./configure CXX=CC
</pre>

<p>
<li>
If you want to use, say, the options <tt>-g</tt>, <tt>-O3</tt>,
compiling <tt>C++</tt>, run:
<pre>
   % ./configure "CXXFLAGS=-g -O3"
</pre>


<p>
If GMP was installed in 
 <tt>$HOME/sw</tt>,
run:
<pre>
   % ./configure GMP_PREFIX=$HOME/sw
</pre>
Go <a href="tour-gmp.html">here</a> for complete details.


<p>
<li>
If <a href="tour-gf2x.html"><tt>gf2x</tt></a>  
is installed in a standard system directory, and you want to use it
to obtain better performance for polynomial arithemtic over <i>GF(2)</i>, 
run:
<pre>
   % ./configure NTL_GF2X_LIB=on
</pre>
If <tt>gf2x</tt> was installed in 
 <tt>$HOME/sw</tt>,
run:
<pre>
   % ./configure NTL_GF2X_LIB=on GF2X_PREFIX=$HOME/sw
</pre>
Go <a href="tour-gf2x.html">here</a> for complete details.

<p>
<li>
If you want to install NTL in the directory <tt>$HOME/sw</tt>,
run:
<pre>
   % ./configure PREFIX=$HOME/sw
</pre>
</ul>

<p>
There are a number of more esoteric configuration variables that can be set.
See <a href="config.txt"><tt>config.txt</tt></a> for a complete
description.

<p>
Note that many of these configuration options can also be set
by editing the two files <tt>makefile</tt>
and <tt>../include/NTL/config.h</tt> by hand.
These files are fairly simple and well documented, and so this is not
too hard to do.

<p>
Note that the file "<tt>../include/NTL/def_config.h</tt>"
contains a backup copy of the original <tt>config.h</tt> file,
and that the file "<tt>def_makefile</tt>"
contains a backup copy of the original <tt>makefile</tt> file.




<p>
<b>Step 3.</b>
Execute <tt>make</tt>.

<p>
Just type:
<pre>
   % make
</pre>

<p>
The build  process after this point is fully automatic.
But here is a description of what happens.

<p>

<ol>
<li>
The makefile 
builds the file "<tt>../include/NTL/mach_desc.h</tt>", which defines some machine characteristics
such as word size and machine precision.
This is done by compiling and running a <tt>C</tt> program
called <tt>MakeDesc</tt>
that figures out these characteristics on its
own, and prints some diagnostics to the terminal.

<p>
<li>
Several scripts are run to obtain more information
about your system (e.g.,
to find a timing function, a "getpid" function, 
and to detect if things like Intel AVX intrinsics work).


<p>
<li>
The file  "<tt>../include/NTL/gmp_aux.h</tt>"
is generated for use with GMP.
If not using GMP, this file is still created, but it is empty.


<p>
<li>
The configuration wizard script is run.
This script works in a sub-directory, 
compiling several programs,
and performing a number of timing experiments,
in order to determine the optimal setting for a number of flags
in the file <tt>../include/NTL/config.h</tt>.
When the script finishes (it may take several minutes),
you will be told what the wizard thinks are the best settings,
and your <tt>config.h</tt> file will be automatically updated.
Note that any flags you set in Step 2 
will be in
effect while the wizard runs, and will be retained in the updated
<tt>config.h</tt> file, with the exception of the flags
<pre>
   NTL_LONG_LONG NTL_AVOID_FLOAT NTL_TBL_REM NTL_TBL_REM_LL NTL_AVOID_BRANCHING 
   NTL_SPMM_ULL NTL_SPMM_ASM NTL_GF2X_NOINLINE NTL_GF2X_ALTCODE
   NTL_GF2X_ALTCODE1 NTL_FFT_LAZYMUL NTL_FFT_BIGTAB NTL_PCLMUL
</pre>
which are set by the wizard. 
Also note that if you <i>do not</i> want the wizard to run,
you should pass <tt>WIZARD=off</tt> to the configure script;
however, this is not recommended.

<p>
<li>
The makefile will compile all the source files,
and then creates the library "<tt>ntl.a</tt>" in the current directory.
</ol>

<p>
Note that for finer control  you can optionally  break up this process 
into the five
component steps:
<pre>
   % make setup1
   % make setup2
   % make setup3
   % make setup4
   % make ntl.a
</pre>


<p>

<p>
<b>After NTL is built.</b>

<p>
Executing <tt>make check</tt> runs a series of timing and test programs.
It is a good idea to run this to see if everything really
went well.

<p>
Executing <tt>make install</tt>
copies a number of files to a directory <tt>&lt;prefix&gt;</tt> that you
specify by passing <tt>PREFIX=&lt;prefix&gt;</tt>
as an argument to <tt>configure</tt> at configuration time,
or as an argument to <tt>make install</tt> at installation time
(e.g., <tt>make install PREFIX=/path/to/sw</tt>).
The default is <tt>/usr/local</tt>, so either you need root 
permissions, or you choose a <tt>&lt;prefix&gt;</tt> for which
you have write permission.
The files <tt>../include/NTL/*</tt> are copied into
<tt>&lt;prefix&gt;/include/NTL</tt>.
The file <tt>ntl.a</tt> is copied to <tt>&lt;prefix&gt;/lib/libntl.a</tt>.
The files <tt>../doc/*</tt> are copied into
<tt>&lt;prefix&gt;/share/doc/NTL</tt>.

<p>
You can also "fine tune" the installation procedure further.
See the <a href="config.txt">configure documentation</a> for details.

<p>
Executing <tt>make uninstall</tt> undoes <tt>make install</tt>.


<p>
Executing <tt>make clobber</tt> essentially
undoes <tt>make</tt>.
<i>Make sure you do this if you re-build NTL for a different architecture!</i>

<p>
Executing <tt>make clean</tt> will remove object files, but not 
<tt>ntl.a</tt>.
To rebuild after executing <tt>make clean</tt>, execute <tt>make ntl.a</tt>.


<p>
<h2>
<a name="shared">
Building a Shared Library
</a>
</h2>
<p>


By default, the above installation procedure builds
a <i>static</i> library only.
Static libraries are nice because the procedures for building
and using them are nearly identical across various flavors
of Unix.
However, static libraries have their drawbacks, and sometimes
it is desirable to build a <i>shared</i> library.
This can be done (in theory) by simply passing <tt>SHARED=on</tt> to 
NTL's <tt>configure</tt>.

<p>
If you set <tt>SHARED=on</tt>, then behind the scenes,
the procedure used by the <tt>makefile</tt> changes a bit.
In particular, the magical GNU program <tt>libtool</tt> is used
to deal with all idiosyncracies of shared libraries.
You may need to set the
configuration variable <tt>LIBTOOL</tt>, to point to another version of
<tt>libtool</tt>.  
For example, on <i>Mac OSX</i>, the built-in command called <tt>libtool</tt>
is not
actually the GNU <tt>libtool</tt> program; 
in this case, you will want to set
<tt>LIBTOOL=glibtool</tt>.  
On other systems, it may be necssary to download and
install a fresh copy of the libtool program (which can be obtained from
<a href="http://www.gnu.org/software/libtool">here</a>). 
Note that if <tt>SHARED=on</tt>, then 
in addition to using the <tt>libtool</tt> program, the <tt>makefile</tt> 
relies on
features specific to GNU make.

<p>
Note that if you want to build NTL as a shared library,
then if you use them, GMP and <tt>gf2x</tt> must also 
be built and installed as shared libraries.
Also note that to use a shared library version of NTL,
you may have to do something special, like set a special
shell variable:  the output generated by the <tt>libtool</tt>
program during <tt>make install</tt> should give specific
instructions.
In addition, if NTL is built as a shared library, then
you typically do not have to include <tt>-lgmp</tt> (if using GMP),
or <tt>-lgf2x</tt> (if using <tt>gf2x</tt>), or corresponding
<tt>-L</tt> flags, or <tt>-lm</tt>  
on
the command line when compiling programs that use NTL.


<p>
<h2>
<a name="abi">
32-bit and 64-bit ABIs
</a>
</h2>
<p>


An ABI (Application Binary Interface) defines the sizes of various 
<tt>C</tt> data types.
Typically, with a 32-bit ABI, int's and long's are 32 bits,
while on a 64-bit ABI, int's are 32 bits and long's are 64 bits.
Some platforms 
support both 64-bit and 32-bit ABI's;
typically in such settings, the 64-bit ABI will yield much better
performance, while the 32-bit ABI is available for backward compatibility.
In addition, the 64-bit ABI may <i>not</i> be the default:
if you are using <tt>gcc</tt>, you need to pass the <tt>-m64</tt>
flag to the compiler to get the 64-bit ABI.

<p>
When compiling NTL, you may want to try running <tt>configure</tt>
with <tt>CFLAGS="-O2 -m64"</tt> to force a 64-bit ABI -- this 
may yield a very marked performance improvement.

<p>
If you are using NTL with either the GMP or <tt>gf2x</tt> libraries,
then these must be built with the same ABI as NTL.
The installation script for GMP will typically select the 64-bit ABI
automatically if it is available.
The installation script for <tt>gf2x</tt> may need some hints.

<p>
When compiling programs that use NTL, you must also ensure that
the program is compiled with the same ABI as NTL.
Again, if you want a 64-bit ABI, then just pass the flag <tt>-m64</tt>
to the compiler.





<p> <p>
<p> <p>

<center>
<a href="tour-modules.html"><img src="arrow1.gif" alt="[Previous]" align=bottom></a>
 <a href="tour.html"><img src="arrow2.gif" alt="[Up]" align=bottom></a> 
<a href="tour-win.html"> <img src="arrow3.gif" alt="[Next]" align=bottom></a>
</center>

</body>
</html>