Who has time to read long installation manuals these days?
When building netCDF-4, you must first decide whether to support the use of HDF5 as a storage format.
If you don't want netCDF-4/HDF5, then build like this:
./configure --prefix=/home/ed/local --disable-netcdf-4 make check install
(Replace “/home/ed/local” with the name of the directory where netCDF is to be installed.)
If you get the message that netCDF installed correctly, then you are done!
If you want to use the HDF5 storage format, you must have the HDF5 1.8.4-patch1 release. You must also have the zlib compression library, version 1.2.3 (or better). Both of these packages are available from the netCDF-4 ftp site at ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.
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.
Optionally, you can also build netCDF-4 with the szip 2.0 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 HDF5 web page: http://hdf.ncsa.uiuc.edu/doc_resource/SZIP/Commercial_szip.html. 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 you wish to use szip, get it from the HDF5 download page: http://hdfgroup.org/HDF5//HDF5/release/beta/obtain518.html.
If “make check” fails for either zlib or HDF5, the problem must be resolved before the netCDF-4 installation can continue. For HDF5 problems, send email to the HDF5 help desk: help@hdfgroup.org.
Build zlib like this:
./configure --prefix=/home/ed/local make check install
(If you want a shared library build of HDF5, you must set CFLAGS to -fPIC before building zlib.)
Then you build HDF5, specifying the location of the zlib library:
./configure --with-zlib=/home/ed/local --prefix=/home/ed/local --disable-shared make check install
This builds a static version of the HDF5 library. For a shared build, don't use –disable-shared. For a shared build to work you must have compiled zlib (and, optionally, szip) with CFLAGS=-fPIC. In this case you may need to add the install directory to the LD_LIBRARY_PATH environment variable. See the FAQ for more details on using shared libraries: http://www.unidata.ucar.edu/netcdf/faq.html.
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-4, specifying the location of the HDF5, zlib, and (if built into HDF5) the szip libraries with the –with-hdf5, –with-zlib, and –with-szlib option. (If they are all in the same directory, you only need to use one of these options.)
./configure --with-hdf5=/home/ed/local --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. For example, 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.
The default install root is /usr/local (so there's no need to use the prefix argument if you want the software installed there).
If HDF5 and zlib are found on your system, they will be used by netCDF in the build. To prevent this use the –disable-netcdf-4 argument to configure.
By default the netCDF configuration will build static libraries only. For shared libraries as well, use the –enable-shared option to configure.
To use netCDF-4 you must link to all the libraries, netCDF, HDF5, zlib, and (if used with HDF5 build) szip. This will mean -L options to your build for the locations of the libraries, and -l (lower-case L) for the names of the libraries.
For example, one user reports that she can build other applications with netCDF-4 by setting the LIBS envoronment variable:
LIBS='-L/X/netcdf-4.0/lib -lnetcdf -L/X/hdf5-1.8.4/lib -lhdf5_hl -lhdf5 -lz -lm -L/X/szip-2.1/lib -lsz'
The nc-config command can be used to learn what options are needed for the local netCDF installation.
The netCDF-4 library can (since version 4.1) read HDF4 data files, if they were created with the SD (Scientific Data) API. To enable this feature, use the –enable-hdf4 option. The –with-hdf4= option may be used to specify a location for the HDF4 library.