back

Setting HDF5 API version

Recently (April 2014) I have encountered problems in compiling applications with HDF5 library. Sample error messages are here:

Hdf5IO.cpp:25:110: error: too many arguments to function ‘hid_t H5Dcreate1(hid_t, const char*, hid_t, hid_t, hid_t)’
   *dataset_id = H5Dcreate(*file_id, name, H5T_NATIVE_INT, *dataspace_id,H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT);

Envrionment: Debian 6.0.9, HDF5 version 1.8.4-patch1-2, installed form packages.

The root of the problem is in the API change between version 1.6 and 1.8. HDF5 library is shipped with both interfaces, and macros to select one of them.

Unfortunately Debian version of HDF library is compiled with default API mapping for 1.6, see /usr/lib/libhdf5.settings :

         Default API Mapping: v16

I have looked at the organisation of header files but due the way macros are defined I do not see a nice way to change this default version.

There are two possible solutions:

  1. Use the HDF5 provided macros to select API version for each API function overriding the global settings. This amounts to define
      #define H5Dopen_vers 2
      #define H5Dcreate_vers 2

    before including hdf5.h

  2. Copy file H5public.h localy that it will be included before system file. Then modify it by undefining H5_USE_16_API, that is:
      #include "H5pubconf.h"    /*from configure  */
      #undef H5_USE_16_API

The undef statement above should be after inclusion of H5pubconf.h because this is the file where H5_USE_16_API is defined.

Anyway, problem is small but annoying :-).

back

  • en/research/notebook/hdf5api.txt
  • Last modified: 2017/10/02 15:54
  • (external edit)