Not able to link HDF5 path in CMake configuration

I’m trying to create make files of C++ code on a server doing

cmake …/

and I get the error

– Could NOT find HDF5 (missing: HDF5_INCLUDE_DIRS) (found version “1.10.7”)
CMake Error at src/CMakeLists.txt:180 (message):
HDF5 support was requested, but no HDF5 library was found on this system

I have installed HDF5 in /home/directory/ so I have HDF5 include and library files in

/home/directory/include

/home/directory/lib

I’ve tried to add in CMakeLists.txt the following lines:

set(HDF5_LIBRARIES “/home/directory/”)

set(HDF5_CXX_LIBRARIES “/home/directory/”)

set(HDF5_INCLUDE_DIRS “/home/directory/”)

set(HDF5_CXX_INCLUDE_DIRS “/home/directory/”)

But still getting the error. I’ve also tried to export HDF5_ROOT=/home/directory/ without success.

The error come from the following lines in the code:

if (HDF5_FOUND)
target_include_directories(soft PUBLIC ${HDF5_INCLUDE_DIRS})
target_link_libraries(soft PUBLIC ${HDF5_LIBRARIES})
else (HDF5_FOUND)
message(FATAL_ERROR “HDF5 support was requested, but no HDF5 library was found on this system”)
endif (HDF5_FOUND)

I installed HDF5 using this 2. Quick installation
https://fossies.org/linux/hdf5/release_docs/INSTALL

Any help?

Using CMake 3.19.3 and hdf5-1.10.7

The libraries setting needs to specify the library name.
However, since your using CMake, why not use the find package command - which will also need the cmake config files (which would be in a share directory. Did you build your own hdf5 or use a pre-built binary?

The pre-built binary include an examples project which can be inspected for how to use the find package. The release_docs/USING_HDF5_CMake.txt doc from the source also descibes this process.

Allen

Dear Allen
I realized the problem were 2:

  • not including --enable-cxx in HDF5 installation
  • not including -DHDF5_ROOT when running CMake command

But I still have a problem.
The HDF5 file libhdf5_cpp.so.103 is looking for libstdc++.so.6.
The point is that he’s looking in the old version /usr/lib64/libstdc++.so.6 instead the new one in /somepath/lib64/libstdc++.so.6

Do you know at which point I should specify where to point?
I tried setting -DLD_LIBRARY_PATH=/somepath/lib64/ without success…

No, I do not know of anything in HDF CMake code that controls that. I believe that is a system specific issue, maybe some searching for CMake and default lib path might be of help.

Allen

Thanks Allen.

I solved it using export LD_LIBRARY_PATH=/somepath/lib64/

Thanks for the help.

Giorgio