wiki:HDF

Version 2 (modified by warmerdam, 17 years ago) ( diff )

added note about building to fix netcdf issue.

There are two HDF formats, HDF4, and HDF5 which each have their own libraries and drivers. HDF4 is more common, but HDF5 is the next generation format.

Building with HDF4

NCSA HDF library can be downloaded from the The NCSA HDF Home Page at the the National Center for Supercomputing Applications. HDF 4.2r1 is generally the preferred version if working from source. The szip option is not widely used, and may be omitted for simplicity.

If your OS distribution already contains prebuilt HDF library you can use one from the distribution.

Open File Limits

Please note, that NCSA HDF library compiled with several defaults which is defined in hlimits.h file. For example, hlimits.h defines the maximum number of opened files:

#   define MAX_FILE   32

If you need open more HDF4 files simultaneously you should change this value and rebuild HDF4 library (there is no need to rebuild GDAL if it is already compiled with HDF4 support).

Incompatibility with NetCDF Libraries

The HDF4 libraries include an implementation of the netcdf api which can access hdf files. If building with HDF4 and NetCDF it is necessary to build the HDF library with this disable. This can be accomplished by defining the macro HAVE_NETCDF when building the HDF libraries. I normally accomplish this by configuring the HDF4 libraries as follows:

export CFLAGS="-fPIC -DHAVE_NETCDF"
export CXXFLAGS="-fPIC -DHAVE_NETCDF"
export LIBS="-lm"
./configure --disable-fortran

The -fPIC and LIBS may not be necessary on all platforms. Without this fix either GDAL will crash intermittently when accessing netcdf files, or the build of GDAL will fail.

Note: See TracWiki for help on using the wiki.