#

A Tour of NTL: Obtaining and Installing NTL for Windows

The WinNTL distribution of NTL can be used on any Windows platform. The source code is identical to the UNIX NTL distribution; only the packaging is slightly different. The config.h and mach_desc.h files are geared towards Windows and the MSVC++ compiler.

Windows Users: you should consider using a Unix emulation environment like Cygwin or MinGW, instead of Microsoft development tools.

Why?

- These environments use gcc, which generally adheres closer to language standards and produces more efficient code that Microsoft's compiler.

- With these environments, you can use NTL's Unix distribution, and the installation is almost entirely automatic: no pointing and clicking -- not much more than `./configure` and `make`. You can also easily to install GMP and run NTL's performance-tuning Wizard. These factors combined can make a hige difference in performance, easily giving you a huge (10x or more) performance improvement.

- On 64-bit machines, you should definitely consider Cygwin: the 64-bit version of Cygwin gives you an LP64 data model, which for many reasons is preferable to the Windows data model. In particular, you will get the most performance out of NTL in this environment.

The remaining instructions on this page only apply if you do not use a Unix emulation environment like Cygwin or MinGW.

If you really want to get the most out of NTL, please stop, and seriously consider using a Unix emulation environment and NTL's Unix distribution. Your code will be much snappier, and your quality of life will be much better.

You have been warned.

Obtaining and unpacking NTL.

To obtain the source code and documentation for NTL, download `WinNTL-xxx.zip`. Here, "`xxx`" is the current version number. Then `unzip` this file into a directory (folder). This will unpack everything into a directory called "`WinNTL-xxx`". Inside this directory, you will find several directories.

- The directory "`doc`" contains all of NTL's documentation, including this "tour" ("`tour.html`") and the "`.txt`" files explaining each module, which can be accessed directly, or through the "tour".

- The directory "`src`" contains all of the source files for the library, all with "`.cpp`" extensions.

- The directory "`include`" contains a single directory called "`NTL`", and the latter contains all of the "`.h`" files.

Platform dependent macros.

In directory "`include/NTL`" there is a file called "`mach_desc.h`", which contains all of the platform-dependent macro definitions. The default settings should be good for Windows with MSVC++.

You might consider compiling and running the program `MakeDesc`, whose source files are in directory "`MakeDesc`". This program will dynamically build a correct "`mach_desc.h`" for your platform (processor, compiler, run-time environment). To get accurate results, you must compile this program using the level of optimization (or higher) that you will use for NTL. The program will print some diagnostics to the screen, and create the file "`mach_desc.h`" (in the current directory, and not in the "`include/NTL`" directory, where it needs to go).

Configuration flags.

Also in directory "`include/NTL`" is a file called "`config.h`". You can edit this file to override some of NTL's default options for basic configuration and performance. Again, the defaults should be good for Windows with MSVC++.

Test programs.

The directory "`tests`" contains several test programs. For each program `FooTest`, there is a source file "`FooTest.cpp`", and optionally two files "`FooTestIn`" and "`FooTestOut`". If the latter exist, then the program should be run with the "`FooTestIn`" as standard input; correct output (printed to standard output) should match the contents of "`FooTestOut`" exactly; note that these programs also print diagnostic output on the screen (through standard error output).

Timing functions.

The directory "`GetTime`" contains several alternative definitions of the `GetTime()` function. The file "`GetTime.cpp`" in the "`src`" directory should be good for Windows with MSVC++. In a different environment, one of the definitions in the directory "`GetTime`" better.

Other tools.

The directory "`misc`" contains the program `gen_gmp_aux.cpp` that automatically generates the auxilliary file needed when using NTL with GMP. You will have to look at the makefile in the Unix distribution to see how to use these.

Compiling NTL.

It is straightforward to install NTL on Windows with MSVC++, even though it involves a lot of annoying pointing and clicking. First, compile all of the files in "`src`", and create a static library. Make sure the compiler knows where to find NTL's include files (directory "`include`" and not "`include/NTL`") Then, to compile a program using the library, make sure the compiler knows about the library and the directory of NTL's include files.

Here is a link to a video showing how NTL can be built using a Microsoft compiler.

Further remarks.

TIP: When writing programs using NTL, you should include files using the syntax

       #include <NTL/ZZ.h>

and not using a backslash ("`\`") as a delimiter.

TIP: When writing windows applications using NTL (as opposed to console applications) you might want to compile your program with the `NTL_NO_MIN_MAX` macro defined. This suppresses the declaration of several `min` and `max` functions in file `tools.h` that conflict with macro names in the MFC header files. Do not attempt to build the library with this macro defined -- only programs that use the library. Another solution is to define the macro `NOMINMAX`, which will tell the Microsoft compiler to not define min/max macros.