Computer Setup
[HDF5] Trouble shooting (+fortran)
astrodoo
2021. 7. 13. 23:54
After completing the installation with cmake, sometimes it is needed to update the library path,
export LD_LIBRARY_PATH=/directory/hdf5/lib/installed:$LD_LIBRARY_PATH
One issue I had was that even though I enabled Fortran setup in CMake option during the installation,
fortran-hdf5 libraries were not working. This is simply because the link of "include" should be directed to "shared".
For example,
ifort test_hdf5.f90 -I/home/wanga/CMake-hdf5-1.12.0/HDF_Group/HDF5/1.12.0/include -L/home/wanga/CMake-hdf5-1.12.0/HDF_Group/HDF5/1.12.0/lib -lhdf5_fortran
This caused an error like:
/home/wanga/CMake-hdf5-1.12.0/HDF_Group/HDF5/1.12.0/h5fc
dir is /home/wanga/CMake-hdf5-1.12.0/HDF_Group/HDF5/1.12.0
Package hdf5 was not found in the pkg-config search path.
Perhaps you should add the directory containing `hdf5.pc'
to the PKG_CONFIG_PATH environment variable
Package 'hdf5', required by 'hdf5_fortran-1.12.0', not found
test.hdf5: file not recognized: file format not recognized
The change was simply adding "shared" folder in the "include (-I)", which has all "*.mod" files.
ifort test_hdf5.f90 -I/home/wanga/CMake-hdf5-1.12.0/HDF_Group/HDF5/1.12.0/include/shared -L/home/wanga/CMake-hdf5-1.12.0/HDF_Group/HDF5/1.12.0/lib -lhdf5_fortran