[Previous] [Up] [Next]

A Tour of NTL: Obtaining and Installing NTL for Windows and other Platforms

The WinNTL distribution of NTL can be used on any Windows platform (Windows 95 or later). Actually, there is nothing Windows-specific about WinNTL. The source code is identical to the UNIX NTL distribution; only the packaging is slightly different, and no assumptions are made about the program development environment. Thus, it should be possible to install WinNTL on other operating systems with little difficulty.

MAC OSX Users: since MAC OSX is essentially just a (rather funny) flavor of Unix, you will be much better served using the Unix distribution.

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


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.

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 correct for any system running Windows; however, the correct definitions can depend on the compiler and run-time environment. Therefore, to be on the safe side, 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. Note that the file "def_config.h" contains a backup copy of the original config.h file.

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 OK, but your compiler might like one of the definitions in the directory "GetTime" better.

Other tools.

The directory "misc" contains a program newnames.cpp to help make the transition to NTL version 3.5 from earlier versions of NTL. See the changes section for more details. It also contains the programs gen_lip_gmp_aux.cpp and gen_gmp_aux.cpp that automatically generate the auxilliary files 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.

Since there are a number of incompatible compilers and program development environments available for Windows, no attempt has been made to provide automatic tools for building and testing, as is done for the Unix distribution. Nevertheless, it should be straightforward to install NTL (even if it involves a bit of 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. In any case, if you want to do any serious computations, you will certainly want to compile everything with your compiler's code optimizer on.

Here a a link to a video showing how NTL can be built using a Microsoft compiler. To me, it looks very complicated: I recommend MinGW or Cygwin.

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.

[Previous] [Up] [Next]