Previous: The NetCDF Web Site Next: Getting Support Table of contents Frames 2010 Unidata NetCDF Workshop > Overview of netCDF

3.6 Installing netCDF
NetCDF is easy to build and install from source using the most recent autotools-based package.

On many platforms, it only requires expanding the compressed distribution and running the following commands:

     ./configure
     make check install

Shared libraries will be built by default after version 4.1.2. For earlier versions, if you want shared libraries use:

     ./configure --enable-shared
     make check install

There are many options available for configuring netCDF builds. Use the --help option to learn more.

     ./configure --help

If you want to use the netCDF-4/HDF5 data format, you must first install the zlib and HDF5-1.8.5 libraries, and build netCDF like this:

     ./configure --with-hdf5=/location/of/hdf5
     make check install

To be able to read HDF4 SD data files, you must specify --enable-hdf4, and optionally the location of HDF4 like this:

     ./configure --with-hdf5=/location/of/hdf5 --enable-hdf4 --with-hdf4=/location/of/hdf4
     make check install

The UDUNITS package is now available with the netCDF build. Use the --with-udunits configure option to install it. UDUNITS is a mature package which supports unit conversions.

     ./configure --with-udunits
     make check install

The experimental libcf package is also available with the netCDF build. Use the --with-libcf configure option to install it. Libcf helps read and write data files which use the CF (Climate and Forecast) conventions, used to annotate Earth system data.

     ./configure --with-libcf
     make check install

Frequently you will want to set some flags for the pre-processors, compilers, and linker.

CPPFLAGS - C pre-processor flags
CFLAGS - C compiler flags
FCFLAGS - Fortran compiler (77 & 90) flags
F77FLAGS - Fortran 77 (only) compiler flags
F90FLAGS - Fortran 90 (only) compiler flags
CXXFLAGS - C++ compiler flags
LDFLAGS - Loader flags
LIBS - Library flags

Many options can be combined

     CC=gcc CFLAGS='-g -Wall' ./configure --with-libcf --with-udunits
     --enable-hdf4 --with-hdf4=/machine/local
     --with-hdf5=/machine/local_hdf5 --enable-shared
     make check install

If you run into problems, check these sources of help:

 


Previous: The NetCDF Web Site Next: Getting Support Table of contents Frames 2010 Unidata NetCDF Workshop > Overview of netCDF