wiki:HDF

Version 4 (modified by frankie, 16 years ago) ( diff )

Updated for current HDF4

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. On more recent HDF4 releases it has been added a new configuration flags, so that you have to use

./configure --disable-netcdf --disable-fortran

and HDF4 will move NetCDF functions in a different private namespace to avoid name clashes.

Potential conflicts with internal libz

The HDF4 libraries depend on libz library. If you build HDF4 from sources, you most likely use libz library already installed in your system. Then, when you run GDAL ./configure script using option --with-libz=internal requesting GDAL to use its internal version of libz, you may notice that HDF4 support is not enabled as you expected. This might signal a conflict between internal libz and the version installed in you system against which HDF libraries were linked. More detailed description of the problem and its symptoms can be found in summary of Ticket #1955.

Note: See TracWiki for help on using the wiki.