3
votes

First of all, I read a similar StackOverflow question here, but it doesn't solved my problem.

I would like to use the HDF5 files in my Fortran-2008 projects, so I need to get the static and dynamic HDF5 libraries files to usem them.

What I already did:

  1. I downloaded and installed the HDF5 Windows 10 x64 VS15 binary from the HDF5 official web site (here).

  2. I tested it running this command inside the Windows console: h5dump.exe. It works good!

  3. So I copy one basic HDF5 Fortran example and paste it on a new Visual Studio Fortran project. Fortran example source-code (here)
  4. Then, under Project Properties | Fortran | General | Additional Include Directories insert the path to the location of hdf5.mod

C:\Program Files\HDF_Group\HDF5\1.10.5\include\static

  1. To link, under Project | Properties | Linker | General | Additional Library Directories insert the path the location of the .lib files.

C:\Program Files\HDF_Group\HDF5\1.10.5\lib

  1. Then, under Project | Properties | Linker | Input | Additional Dependencies insert ONLY the hdf5_fortran.lib

I did all these configurations for All Configurations and All Platforms. My active VS environment is Debug - x64.

Problem

I right-clicked in the Fortran solution name and "Build", but I got these linker errors:

unresolved external symbol H5GLOBAL_mp_H5T_NATIVE_INTEGER
unresolved external symbol H5GLOBAL_mp_H5FD_MEM_NTYPES_F
unresolved external symbol H5GLOBAL_mp_H5F_ACC_TRUNC_F

a) What I have to do now to solve it?

b) The HDF5 binary installer name (hdf5-1.10.5-Std-win10_64-vs15.zip) have this vs15 inside the filename. I don't know, but I think that it means "Visual Studio 2015". Is there any problem to use these C and Fortran HDF5 libraries inside of Visual Studio 2019 x64?

My system is:

  • Windows 10 x64
  • Visual Studio 2019 Enterprise
  • Intel Visual Fortran 2019

Fortran Example Source-Code:

! This example is used in the HDF5 Tutorial.

PROGRAM H5_CRTDAT

  USE HDF5 ! This module contains all necessary modules

  IMPLICIT NONE

  CHARACTER(LEN=8), PARAMETER :: filename = "dsetf.h5" ! File name
  CHARACTER(LEN=4), PARAMETER :: dsetname = "dset"     ! Dataset name

  INTEGER(HID_T) :: file_id       ! File identifier
  INTEGER(HID_T) :: dset_id       ! Dataset identifier
  INTEGER(HID_T) :: dspace_id     ! Dataspace identifier


  INTEGER(HSIZE_T), DIMENSION(2) :: dims = (/4,6/) ! Dataset dimensions
  INTEGER     ::   rank = 2                        ! Dataset rank

  INTEGER     ::   error ! Error flag

  !
  ! Initialize FORTRAN interface.
  !
  CALL h5open_f(error)

  !
  ! Create a new file using default properties.
  !
  CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error)

  !
  ! Create the dataspace.
  !
  CALL h5screate_simple_f(rank, dims, dspace_id, error)

  !
  ! Create the dataset with default properties.
  !
  CALL h5dcreate_f(file_id, dsetname, H5T_NATIVE_INTEGER, dspace_id, &
       dset_id, error)

  !
  ! End access to the dataset and release resources used by it.
  !
  CALL h5dclose_f(dset_id, error)

  !
  ! Terminate access to the data space.
  !
  CALL h5sclose_f(dspace_id, error)

  !
  ! Close the file.
  !
  CALL h5fclose_f(file_id, error)

  !
  ! Close FORTRAN interface.
  !
  CALL h5close_f(error)

END PROGRAM H5_CRTDAT
1

1 Answers

1
votes

The include directory for the HDF5 Fortran module is for the statically linked form of the library, but you've then specified the lib file for the dynamically linked (shared) form.

If you want the dynamically linked form of the library, then change the include path to be C:\Program Files\HDF_Group\HDF5\1.10.5\include\shared. (If you use dynamic linking, then be mindful that the HDF5 installation includes copies of the Fortran runtime libraries from the version of the compiler used to compile HDF5. If the version of the compiler used to compile HDF5 is older than the version you are using for the rest of your program, then this will cause issues.)

If you want the statically linked form of the library, then change the libraries to the libhdf_fortran.lib variant. You will need to add other libhd5* libraries to the link as well.

(The dynamic/static form for the C runtime library will also need to match the setting when the static HDF5 libraries were compiled.)