hdf images hdf images

This web site is no longer maintained (but will remain online).
Please see The HDF Group's new Support Portal for the latest information.

Compiling your HDF5 Applications


Tools and Instructions on Compiling

See the Obtain Latest page for obtaining the HDF5 pre-built binary distribution and source code.


For Windows platforms, see the FAQ for information on compiling an application.


For Unix platforms, the following compile scripts are included with the binary distribution of the HDF5 software:

h5cc:   compile script for HDF5 C programs.
h5fc:   compile script for HDF5 F90 programs.
h5c++:   compile script for HDF5 C++ programs.

Examples of Using the Unix Compile Scripts:

Following are examples of compiling and running an application with the Unix compile scripts:

   h5fc myprog.f90

   h5cc -o myprog myprog.c

To see the libraries linked in with a compile script use the -show option. For example, if using h5cc type:

   h5cc -show myprog.c



We encourage users to use the compile scripts. Following are example makefiles for those users who do not wish to use the scripts. These makefiles are only minimally tested:

    Fortran Makefile
    C Makefile

Detailed Description of Unix Compile Scripts:

The h5cc, h5c++, and h5fc compile scripts come with the HDF5 source code and binary distributions (include files, libraries, and utilities) for the platforms we support. The h5c++ and h5fc utilities are ONLY present if the library was built with C++ and Fortran.

After you have installed your binaries in their final destination, you can use the scripts to compile. However, if using the pre-built binaries or moving the binaries to a new location, you must:

You may also need to change other variables in the scripts, depending on how things are set up on your system. Here are some of the variables to check:

  prefix      - Path to the HDF5 top level installation directory
  CCBASE      - Name of the alternative C compiler
  CLINKERBASE - Name of the alternative linker
  LIBS        - Libraries your application will link with

For information on settings used to build the HDF5 libraries, please refer to:

    ./lib/libhdf5_fortran.settings (if Fortran enabled)  
    ./lib/libhdf5_cpp.settings (if C++ enabled)

HDF5 Libraries

Following are the libraries included with HDF5. Whether you are using the Unix compile scripts or Makefiles, or are compiling on Windows, these libraries are or may need to be specified. The order they are specified is important:

    libhdf5_hl_cpp.a    - HDF5 High Level C++ APIs 
    libhdf5_cpp.a       - HDF5 C++ Library  
    libhdf5hl_fortran.a - HDF5 High Level Fortran APIs
    libhdf5_fortran.a   - HDF5 Fortran Library
    libhdf5_hl.a        - HDF5 High Level C APIs
    libhdf5.a           - HDF5 C Library

The -show option for h5cc, hc++ and h5fc will display the libraries in the correct order.

External Libraries:

    libsz.a             - SZIP Compression Library
    libz.a              - ZLIB or DEFLATE Compression Library
    (any other system libraries, such as -lrt -lm ...)

You may also see shared versions of these libraries.

The pre-compiled binaries, in particular, are built (if at all possible) with these libraries as well as with SZIP and ZLIB. If using shared libraries you may need to add the path to the library to LD_LIBRARY_PATH.

- - Last modified: 21 December 2016