[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 95 or NT platform (but not on Windows 3.11 or earlier). 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 (e.g., Macintosh, OS/2) 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.

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 x86- or Pentium-based 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.

Basic configuration options.
Most of the these flags are rather esoteric and can be safely ignored.

One exception to this is the NTL_STD_CXX flag (or perhaps just the NTL_PSTD_NNS flag) which you will want to unset if your compiler is too old to handle it. Go here for details.

Another exception are the flags to use GMP for potentially faster long integer arithmetic. See the GMP section for more details. Note that getting GMP to run on Windows is a pain in the neck. If you really want to use GMP, use Unix or Linux!

Performance options.
These flags let you fine tune for best performance. (If you were using Unix, you could run a script that automatically selects the best settings for your platform.)

TIP for Pentium platforms:

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.

For the benefit of those who must use Microsoft Visual C++ on Windows, here are some steps for compiling and using NTL. These steps work with MSVC++ v6. While these steps seem to do the job, there may be other steps that work better. The following steps may be used to build the library, and to build and run program QuickTest, as a simple console application, using the library. The instructions assume you have already unzipped NTL into a directory c:\mystuff, and are running the MSVC++ Development Studio.

I hope these instructions make some sense: I don't know a good language for accuratly describing the particular pointing an clicking steps.


File -> New -> Projects 
   project name: ntl
   location[default]: c:\Program Files\Microsoft Visual Studio\MyProjects\ntl
   Click on Win32 static library
   Click on OK
   pre-compiled headers[default]: no
   MFC support[default]: no
   Click on Finish
   Click on OK

Project -> Add to Project -> Files
   select all files in c:\mystuff\WinNTL-xxx\src and click on OK.

Project -> Settings -> C/C++ 
   Category: Preprocessor.
   Additional include directories: c:\mystuff\WinNTL-xxx\include.
   Click on OK.

Build -> build ntl.lib

File -> New -> Projects -> Win32 Console Application
   project name: test
   location[default]: c:\Program Files\Microsoft Visual Studio\MyProjects\ntl
   Click on Win32 Console Application
   Click on OK
   What kind of windows application...? [default]: An empty project
   Click on Finish
   Click on OK

Project -> Add to Project -> Files
   select the file c:\mystuff\WinNTL-xxx\tests\QuickTest.cpp
   Click on OK

Project -> Add to Project -> Files
   select the file 
      c:\Program Files\Microsoft Visual Studio\MyProjects\ntl\Debug\ntl.lib
   Note: one must select Files of type: Library Files (.lib) to make this
      file visible in the pop-up window.
   Click on OK

Project -> Settings -> C/C++ 
   Category: Preprocessor.
   Additional include directories: c:\mystuff\WinNTL-xxx\include.
   Click on OK.

Build -> build test.exe

Build -> execute test.exe

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.

NTL has been successfully installed and tested on Windows 95 platforms with both the Microsoft and Borland compilers.

If you have installed the Unix tools from Cygnus, then you can use the Unix distribution of NTL. This distribution has been specially tailored to work smoothly with Cygnus tools. For many programmers, this is a much more comfortable and reliable program development environment than commercial systems like those from Microsoft and Borland. And moreover, these Unix tools are free. Of course, an even better approach is to install Linux on your PC.

[Previous] [Up] [Next]