1 | <html> |
---|
2 | <head> |
---|
3 | <title> |
---|
4 | A Tour of NTL: Obtaining and Installing NTL for Windows |
---|
5 | and other Platforms </title> |
---|
6 | </head> |
---|
7 | |
---|
8 | <body bgcolor="#fff9e6"> |
---|
9 | <center> |
---|
10 | <a href="tour-unix.html"><img src="arrow1.gif" alt="[Previous]" align=bottom></a> |
---|
11 | <a href="tour.html"><img src="arrow2.gif" alt="[Up]" align=bottom></a> |
---|
12 | <a href="tour-tips.html"> <img src="arrow3.gif" alt="[Next]" align=bottom></a> |
---|
13 | </center> |
---|
14 | |
---|
15 | <h1> |
---|
16 | <p align=center> |
---|
17 | A Tour of NTL: Obtaining and Installing NTL for Windows |
---|
18 | and other Platforms |
---|
19 | </p> |
---|
20 | </h1> |
---|
21 | |
---|
22 | <p> <hr> <p> |
---|
23 | |
---|
24 | The WinNTL distribution of |
---|
25 | NTL can be used on any Windows 95 or NT platform |
---|
26 | (but not on Windows 3.11 or earlier). |
---|
27 | Actually, there is nothing Windows-specific about WinNTL. |
---|
28 | The source code is identical to the UNIX NTL distribution; |
---|
29 | only the packaging is slightly different, and no assumptions |
---|
30 | are made about the program development environment. |
---|
31 | Thus, it should be possible to install WinNTL on |
---|
32 | other operating systems (e.g., Macintosh, OS/2) |
---|
33 | with little difficulty. |
---|
34 | |
---|
35 | <p> |
---|
36 | <b>MAC OSX Users:</b> |
---|
37 | since MAC OSX is essentially just a (rather funny) flavor of Unix, |
---|
38 | you will be much better served using the |
---|
39 | <a href="tour-unix.html">Unix distribution</a>. |
---|
40 | |
---|
41 | |
---|
42 | <p> |
---|
43 | <b> |
---|
44 | Obtaining and unpacking NTL. |
---|
45 | </b> |
---|
46 | <p> |
---|
47 | |
---|
48 | To obtain the source code and documentation for NTL, |
---|
49 | <a href="http://www.shoup.net/ntl/download.html"> |
---|
50 | download <tt>WinNTL-xxx.zip</tt></a>. |
---|
51 | Here, "<tt>xxx</tt>" is the current version number. |
---|
52 | Then <tt>unzip</tt> this file into a directory (folder). |
---|
53 | This will unpack everything into a directory called "<tt>WinNTL-xxx</tt>". |
---|
54 | Inside this directory, you will find several directories. |
---|
55 | |
---|
56 | <p> |
---|
57 | |
---|
58 | <ul> |
---|
59 | <li> |
---|
60 | |
---|
61 | The directory "<tt>doc</tt>" contains all of NTL's documentation, |
---|
62 | including this "tour" ("<tt>tour.html</tt>") |
---|
63 | and the "<tt>.txt</tt>" files explaining each module, |
---|
64 | which can be accessed directly, or through the "tour". |
---|
65 | |
---|
66 | <p> |
---|
67 | <li> |
---|
68 | |
---|
69 | The directory "<tt>src</tt>" |
---|
70 | contains all of the source files for the library, |
---|
71 | all with "<tt>.cpp</tt>" extensions. |
---|
72 | The file "<tt>lip.cpp</tt>" can be compiled as a C source file |
---|
73 | (this can sometimes yield a marginal performance gain). |
---|
74 | |
---|
75 | <p> |
---|
76 | <li> |
---|
77 | |
---|
78 | The directory "<tt>include</tt>" contains a single directory called |
---|
79 | "<tt>NTL</tt>", |
---|
80 | and the latter contains all of the "<tt>.h</tt>" files. |
---|
81 | |
---|
82 | </ul> |
---|
83 | |
---|
84 | <p> |
---|
85 | |
---|
86 | <b> |
---|
87 | Platform dependent macros. |
---|
88 | </b> |
---|
89 | <p> |
---|
90 | |
---|
91 | In directory "<tt>include/NTL</tt>" there is a file called |
---|
92 | "<tt>mach_desc.h</tt>", |
---|
93 | which contains all of the platform-dependent macro definitions. |
---|
94 | The default settings should be correct for any x86- or Pentium-based |
---|
95 | system running Windows; however, the correct definitions |
---|
96 | can depend on the compiler and run-time environment. |
---|
97 | Therefore, to be on the safe side, |
---|
98 | you might consider compiling and running the program <tt>MakeDesc</tt>, |
---|
99 | whose source files are in directory "<tt>MakeDesc</tt>". |
---|
100 | This program will |
---|
101 | dynamically build |
---|
102 | a correct "<tt>mach_desc.h</tt>" for your platform (processor, compiler, |
---|
103 | run-time environment). |
---|
104 | To get accurate results, |
---|
105 | you must compile this program using the level of optimization |
---|
106 | (or higher) that you will use for NTL. |
---|
107 | The program will print some diagnostics to the screen, |
---|
108 | and create the file "<tt>mach_desc.h</tt>" (in the current |
---|
109 | directory, and not in the "<tt>include/NTL</tt>" directory, |
---|
110 | where it needs to go). |
---|
111 | |
---|
112 | <p> |
---|
113 | <b> |
---|
114 | Configuration flags. |
---|
115 | </b> |
---|
116 | <p> |
---|
117 | |
---|
118 | Also in directory "<tt>include/NTL</tt>" is a file called "<tt>config.h</tt>". |
---|
119 | You can edit this file to override some of NTL's default options |
---|
120 | for <i>basic configuration</i> and <i>performance</i>. |
---|
121 | |
---|
122 | <p> |
---|
123 | |
---|
124 | <dl> |
---|
125 | <dt> |
---|
126 | <i>Basic configuration options.</i> |
---|
127 | <dd> |
---|
128 | Most of the these flags are rather esoteric and can be safely |
---|
129 | ignored. |
---|
130 | <p> |
---|
131 | |
---|
132 | One exception to this is the <tt>NTL_STD_CXX</tt> flag |
---|
133 | (or perhaps just the <tt>NTL_PSTD_NNS</tt> flag) which |
---|
134 | you will want to unset if your compiler is too old |
---|
135 | to handle it. |
---|
136 | <a href="tour-stdcxx.html">Go here</a> for details. |
---|
137 | |
---|
138 | <p> |
---|
139 | |
---|
140 | Another exception are the flags to use GMP for potentially |
---|
141 | faster long integer arithmetic. |
---|
142 | See the <a href="tour-gmp.html">GMP</a> section for more details. |
---|
143 | Note that getting GMP to run on Windows is a pain in the neck. |
---|
144 | If you really want to use GMP, use Unix or Linux! |
---|
145 | |
---|
146 | <p> |
---|
147 | |
---|
148 | <dt> |
---|
149 | <i>Performance options.</i> |
---|
150 | <dd> |
---|
151 | These flags let you fine tune for best performance. |
---|
152 | (If you were using Unix, you could run a script that |
---|
153 | automatically selects the best settings for your platform.) |
---|
154 | |
---|
155 | |
---|
156 | <p> |
---|
157 | <i>TIP for Pentium platforms:</i> |
---|
158 | <ul> |
---|
159 | <li> |
---|
160 | Users running |
---|
161 | on a Pentium, or other x86-like processor, |
---|
162 | will almost surely want to set the <tt>NTL_LONG_LONG</tt> flag, |
---|
163 | or possibly the <tt>NTL_AVOID_FLOAT</tt> flag, in file <tt>config.h</tt> |
---|
164 | to get the best performance for long integer arithmetic. |
---|
165 | If you set either of these flags, you should also set the |
---|
166 | <tt>NTL_TBL_REM</tt> flag as well, to get the best |
---|
167 | performance for <tt>ZZ_pX</tt> arithmetic. |
---|
168 | You might also want to set the <tt>NTL_SPMM_ULL</tt> or <tt>NTL_SMPP_UL</tt> |
---|
169 | flags. |
---|
170 | |
---|
171 | <li> |
---|
172 | These flags can be useful on other platforms as well, |
---|
173 | especially on processors with slow int/float conversion. |
---|
174 | |
---|
175 | <li> |
---|
176 | The best thing is to experiment, and compile and run program <tt>QuickTest</tt> |
---|
177 | to see the impact on the running time of various basic operations. |
---|
178 | </ul> |
---|
179 | </dl> |
---|
180 | |
---|
181 | <p> |
---|
182 | Note that the file "<tt>def_config.h</tt>" |
---|
183 | contains a backup copy of the original <tt>config.h</tt> file. |
---|
184 | |
---|
185 | |
---|
186 | <p> |
---|
187 | <b> |
---|
188 | Test programs. |
---|
189 | </b> |
---|
190 | <p> |
---|
191 | |
---|
192 | The directory "<tt>tests</tt>" contains several test programs. |
---|
193 | For each program <tt>FooTest</tt>, there is a source file |
---|
194 | "<tt>FooTest.cpp</tt>", and optionally two files |
---|
195 | "<tt>FooTestIn</tt>" and "<tt>FooTestOut</tt>". |
---|
196 | If the latter exist, then the program should be run with |
---|
197 | the "<tt>FooTestIn</tt>" as standard input; |
---|
198 | correct output (printed to standard output) should match |
---|
199 | the contents of "<tt>FooTestOut</tt>" exactly; |
---|
200 | note that these programs also print diagnostic output on the screen |
---|
201 | (through standard error output). |
---|
202 | |
---|
203 | <p> |
---|
204 | <b> |
---|
205 | Timing functions. |
---|
206 | </b> |
---|
207 | <p> |
---|
208 | |
---|
209 | The directory "<tt>GetTime</tt>" contains several alternative |
---|
210 | definitions of the <tt>GetTime()</tt> function. |
---|
211 | The file "<tt>GetTime.cpp</tt>" in the "<tt>src</tt>" directory should be OK, |
---|
212 | but your compiler might like one of the definitions in |
---|
213 | the directory "<tt>GetTime</tt>" better. |
---|
214 | |
---|
215 | <p> |
---|
216 | <b> |
---|
217 | Other tools. |
---|
218 | </b> |
---|
219 | <p> |
---|
220 | |
---|
221 | The directory "<tt>misc</tt>" contains a program <tt>newnames.cpp</tt> |
---|
222 | to help make the |
---|
223 | transition to NTL version 3.5 from earlier versions of NTL. |
---|
224 | See the <a href="tour-changes.html">changes</a> section for more details. |
---|
225 | It also contains the programs <tt>gen_lip_gmp_aux.cpp</tt> |
---|
226 | and <tt>gen_gmp_aux.cpp</tt> that automatically generate |
---|
227 | the auxilliary files needed when using NTL with GMP. |
---|
228 | You will have to look at the makefile in the Unix distribution |
---|
229 | to see how to use these. |
---|
230 | |
---|
231 | |
---|
232 | |
---|
233 | <p> |
---|
234 | <b> |
---|
235 | Compiling NTL. |
---|
236 | </b> |
---|
237 | <p> |
---|
238 | |
---|
239 | Since there are a number of incompatible compilers and program development |
---|
240 | environments available for Windows, no attempt has been made to |
---|
241 | provide automatic tools for building and testing, |
---|
242 | as is done for the Unix distribution. |
---|
243 | Nevertheless, |
---|
244 | it should be straightforward to install NTL (even if it involves a bit of |
---|
245 | pointing and clicking). |
---|
246 | First, compile all of the files in "<tt>src</tt>", and create a static library. |
---|
247 | Make sure the compiler knows where to find NTL's include files |
---|
248 | (directory "<tt>include</tt>" and <i>not</i> "<tt>include/NTL</tt>") |
---|
249 | Then, to compile a program using the library, |
---|
250 | make sure the compiler knows about the library and the directory |
---|
251 | of NTL's include files. |
---|
252 | In any case, if you want to do any serious computations, |
---|
253 | you will certainly want to compile everything with your |
---|
254 | compiler's code optimizer on. |
---|
255 | |
---|
256 | <p> |
---|
257 | For the benefit of those who must use Microsoft Visual C++ on Windows, |
---|
258 | here are some steps for compiling and using NTL. |
---|
259 | These steps work with MSVC++ v6. |
---|
260 | While these steps seem to do the job, |
---|
261 | there may be other steps that work better. |
---|
262 | |
---|
263 | The following steps may be used to build the library, |
---|
264 | and to build and run program <tt>QuickTest</tt>, as a simple |
---|
265 | <i>console application</i>, using the library. |
---|
266 | The instructions assume you have already |
---|
267 | unzipped NTL into a directory <tt>c:\mystuff</tt>, |
---|
268 | and are running the MSVC++ Development Studio. |
---|
269 | |
---|
270 | <p> |
---|
271 | I hope these instructions make some sense: |
---|
272 | I don't know a good language for accuratly describing the |
---|
273 | particular pointing an clicking steps. |
---|
274 | |
---|
275 | <p> |
---|
276 | |
---|
277 | <pre> |
---|
278 | |
---|
279 | File -> New -> Projects |
---|
280 | project name: ntl |
---|
281 | location[default]: c:\Program Files\Microsoft Visual Studio\MyProjects\ntl |
---|
282 | Click on Win32 static library |
---|
283 | Click on OK |
---|
284 | pre-compiled headers[default]: no |
---|
285 | MFC support[default]: no |
---|
286 | Click on Finish |
---|
287 | Click on OK |
---|
288 | |
---|
289 | Project -> Add to Project -> Files |
---|
290 | select all files in c:\mystuff\WinNTL-xxx\src and click on OK. |
---|
291 | |
---|
292 | Project -> Settings -> C/C++ |
---|
293 | Category: Preprocessor. |
---|
294 | Additional include directories: c:\mystuff\WinNTL-xxx\include. |
---|
295 | Click on OK. |
---|
296 | |
---|
297 | Build -> build ntl.lib |
---|
298 | |
---|
299 | File -> New -> Projects -> Win32 Console Application |
---|
300 | project name: test |
---|
301 | location[default]: c:\Program Files\Microsoft Visual Studio\MyProjects\ntl |
---|
302 | Click on Win32 Console Application |
---|
303 | Click on OK |
---|
304 | What kind of windows application...? [default]: An empty project |
---|
305 | Click on Finish |
---|
306 | Click on OK |
---|
307 | |
---|
308 | Project -> Add to Project -> Files |
---|
309 | select the file c:\mystuff\WinNTL-xxx\tests\QuickTest.cpp |
---|
310 | Click on OK |
---|
311 | |
---|
312 | Project -> Add to Project -> Files |
---|
313 | select the file |
---|
314 | c:\Program Files\Microsoft Visual Studio\MyProjects\ntl\Debug\ntl.lib |
---|
315 | Note: one must select Files of type: Library Files (.lib) to make this |
---|
316 | file visible in the pop-up window. |
---|
317 | Click on OK |
---|
318 | |
---|
319 | Project -> Settings -> C/C++ |
---|
320 | Category: Preprocessor. |
---|
321 | Additional include directories: c:\mystuff\WinNTL-xxx\include. |
---|
322 | Click on OK. |
---|
323 | |
---|
324 | Build -> build test.exe |
---|
325 | |
---|
326 | Build -> execute test.exe |
---|
327 | |
---|
328 | </pre> |
---|
329 | |
---|
330 | <p> |
---|
331 | <b> |
---|
332 | Further remarks. |
---|
333 | </b> |
---|
334 | <p> |
---|
335 | |
---|
336 | <p> |
---|
337 | <i>TIP:</i> When writing programs using NTL, |
---|
338 | you should include files using the syntax |
---|
339 | <pre> |
---|
340 | #include <NTL/ZZ.h> |
---|
341 | </pre> |
---|
342 | and <i>not</i> using a backslash ("<tt>\</tt>") as a delimiter. |
---|
343 | |
---|
344 | <p> |
---|
345 | <i>TIP:</i> When writing <i>windows applications</i> using NTL |
---|
346 | (as opposed to <i>console applications</i>) you might want to compile |
---|
347 | your program with the <tt>NTL_NO_MIN_MAX</tt> macro defined. |
---|
348 | This suppresses the declaration of several <tt>min</tt> |
---|
349 | and <tt>max</tt> functions in file <tt>tools.h</tt> that conflict |
---|
350 | with macro names in the MFC header files. |
---|
351 | Do not attempt to build the library with this macro defined -- only |
---|
352 | programs that use the library. |
---|
353 | |
---|
354 | <p> |
---|
355 | NTL has been successfully installed and tested |
---|
356 | on Windows 95 platforms with both the |
---|
357 | Microsoft and Borland compilers. |
---|
358 | |
---|
359 | <p> |
---|
360 | If you have installed the Unix tools from |
---|
361 | <a href="http://www.cygnus.com">Cygnus</a>, then you can use the |
---|
362 | <a href="tour-unix.html">Unix</a> distribution of NTL. |
---|
363 | This distribution has been specially tailored to work smoothly |
---|
364 | with Cygnus tools. |
---|
365 | For many programmers, |
---|
366 | this is a much more comfortable and reliable program development environment |
---|
367 | than commercial systems like those from Microsoft and Borland. |
---|
368 | And moreover, these Unix tools are <i>free</i>. |
---|
369 | Of course, an even better approach is to install |
---|
370 | <a href="http://www.linux.org">Linux</a> on your PC. |
---|
371 | |
---|
372 | |
---|
373 | <p> |
---|
374 | |
---|
375 | <center> |
---|
376 | <a href="tour-unix.html"><img src="arrow1.gif" alt="[Previous]" align=bottom></a> |
---|
377 | <a href="tour.html"><img src="arrow2.gif" alt="[Up]" align=bottom></a> |
---|
378 | <a href="tour-tips.html"> <img src="arrow3.gif" alt="[Next]" align=bottom></a> |
---|
379 | </center> |
---|
380 | |
---|
381 | |
---|
382 | </body> |
---|
383 | </html> |
---|