Next: , Previous: Installing DLL, Up: Building on Windows


5.3 Building netcdf.dll with VC++ 6.0

The most recent releases of netCDF aren't tested under VC++ 6.0. (They are tested with VC++.NET). Older versions of the library, notably 3.5.0, did compile with VC++ 6.0, and the instructions for doing so are presented below.

Note that the introduction of better large file support (for files larger than 2 GiB) in version 3.6.0 and greater requires an off_t type of 8 bytes, and it's not clear how, or if, this can be found in VC++ 6.0.

To build the library yourself, get the file ftp://ftp.unidata.ucar.edu/pub/netcdf/contrib/win32/netcdf-3.5.0.win32make.VC6.zip

The makefiles there describe how to build netcdf-3.5 using the using Microsoft Visual C++ 6.x and (optionally) Digital Visual Fortran 6.x. Because of difficulties in getting Microsoft Visual Studio to fall in line with our existing source directory scheme, we chose _not_ to build the system "inside" Visual Studio. Instead, we provide a simple group of "msoft.mak" files which can be used. If you wish to work in Visual Studio, go ahead. Read the section called "Macros" at the end of this discussion.

As of this writing, we have not tried compiling the C++ interface in this environment.

nmake is a Microsoft version of make, which comes with VC 6.0 (and VC 7.0) in directory C:\Program Files\Microsoft Visual Studio\VC98\Bin (or, for VC 7.0, C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin).

To build netcdf, proceed as follows:

unpack source distribution.
copy netcdf-3.5.0.win32make.VC6.zip
copy netcdf-3.5.0.win32make.VC6.zip into the netcdf-3.5.0/src directory, and unzip it from there.
cd src\libsrc; nmake /f msoft.mak
Run this command in src\libsrc. This will build netcdf.lib and netcdf.dll Note: This makefiles make DLLs. To make static libraries see section on static libraries.
nmake /f msoft.mak test
Optionally, in src\libsrc, make and run the simple test.
cd ..\fortran; nmake /f msoft.mak
Optionally build the fortran interface and rebuild dll in ..\libsrc to include the fortran interface. Note Bene: We don't provide a .DEF file, so this step changes the "ordinals" by which entry points in the DLL found. Some sites may wish to modify the msoft.mak file(s) to produce a separate library for the fortran interface.
nmake /f msoft.mak test
(necessary if you want to use fortran code) While you are in src\fortran; nmake /f msoft.mak test This tests the netcdf-2 fortran interface.
cd ..\nctest; nmake /f msoft.mak test
(optional, but recommended) In src\nctest; nmake /f msoft.mak test This tests the netcdf-2 C interface.
cd ..\nc_test; nmake /f msoft.mak test
(optional, but highly recommended) In src\nc_test; nmake /f msoft.mak test This tortures the netcdf-3 C interface.
cd ..\nf_test; nmake /f msoft.mak test
(optional, but highly recommended if you built the fortran interface) In src\nf_test; nmake /f msoft.mak test This tortures the netcdf-3 fortran interface.
..\ncdump; nmake /f msoft.mak
In src\ncdump; nmake /f msoft.mak This makes ncdump.exe.
..\ncgen; nmake /f msoft.mak
In src\ncgen; nmake /f msoft.mak This makes ncgen.exe.
..\ncdump; nmake /f msoft.mak test
(optional) In src\ncdump; nmake /f msoft.mak test This tests ncdump. Both ncgen and ncdump need to be built prior to this test. Note the makefile sets the path so that ..\libsrc\netcdf.dll can be located.
..\ncgen; nmake /f msoft.mak test
(optional) In src\ncgen; nmake /f msoft.mak test This tests ncgen. Both ncgen and ncdump need to be built prior to this test. Note the makefile sets the path so that ..\libsrc\netcdf.dll can be located.
To Install
Copy libsrc\netcdf.lib to a LIBRARY directory. Copy libsrc\netcdf.h and fortran/netcdf.inc to an INCLUDE directory. Copy libsrc\netcdf.dll, ncdump/ncdump.exe, and ncgen/ncgen.exe to a BIN directory (someplace in your PATH).