The usual way of building netCDF requires the HDF5, zlib, and curl libraries.
(And, optionally, the szlib library). Versions required are at least HDF5 1.8.8, zlib 1.2.5, and curl 7.18.0 or later. (Optionally, if building with szlib, get szip 2.0 or later.)
HDF5 1.8.9 and zlib 1.2.7 packages are available from the netCDF-4 ftp site. If you wish to use the remote data client code, then you will also need libcurl, which can be obtained from the curl website.
Make sure you run ``make check'' for the HDF5 and zlib distributions. They are very well-behaved distributions, but sometimes the build doesn't work (perhaps because of something subtly misconfigured on the target machine). If one of these libraries is not working, netCDF will have serious problems.
Note that for building netCDF, it is not necessary to build the HDF5 Fortran, C++, or Java API's. Only the HDF5 C library is used.
Optionally, you can also build netCDF-4 with the szip library (a.k.a. szlib). NetCDF cannot create szipped data files, but can read HDF5 data files that have used szip.
There are license restrictions on the use of szip, see the section on licensing terms in the web page on szip compression in HDF products. These license restrictions seem to apply to commercial users who are writing data. (Data readers are not restricted.) But here at NetCDF World Headquarters, in Sunny Boulder, Colorado, there are no lawyers, only programmers, so please read the szip documents for the license agreement to see how it applies to your situation.
If ``make check'' fails for either zlib or HDF5, the problem must be resolved before the netCDF-4 installation can continue. For HDF5 problems, see the HDF5 help services.
Build zlib like this:
./configure --prefix=/home/ed/local make check install
Then you build HDF5, specifying the location of the zlib library:
./configure --with-zlib=/home/ed/local --prefix=/home/ed/local make check install
In all cases, the installation location specified with the –prefix option must be different from the source directory where the software is being built.
Note that for shared libraries, you may need to add the install directory to the LD_LIBRARY_PATH environment variable. See the netCDF FAQ for more details on using shared libraries.
If you are building HDF5 with szip, then include the –with-szlib= option, with the directory holding the szip library.
After HDF5 is done, build netcdf, specifying the location of the HDF5, zlib, and (if built into HDF5) the szip header files and libraries in the CPPFLAGS and LDFLAGS environment variables. For example:
CPPFLAGS=-I/home/ed/local/include LDFLAGS=-L/home/ed/local/lib ./configure --prefix=/home/ed/local make check install
The configure script will try to find necessary tools in your path. When you run configure you may optionally use the –prefix argument to change the default installation directory. The above examples install the zlib, HDF5, and netCDF-4 libraries in /home/ed/local/lib, the header file in /home/ed/local/include, and the utilities in /home/ed/local/bin. If you don't provide a –prefix option, installation will be in /usr/local/, in subdirectories lib/, include/, and bin/. The installation location specified with the –prefix option must be different from the source directory where the software is being built.