I want to use the HDF5 libraries in my C++ program. I am using the VS 2010 x64 compiler and CMake 3.8.0rc2 on Windows 7. The HDF5 version I installed is 1.8.10 (installed by running the official "Installer").
In my CMakeLists file, I added the following lines:
FIND_PACKAGE ( HDF5 REQUIRED )
INCLUDE_DIRECTORIES (${HDF5_INCLUDE_DIRS})
SET (HDF5_LIBS ${HDF5_LIBS} ${HDF5_LIBRARIES})
...
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES} ${HDF5_LIBS})
CMake shows the following error message upon Configuring:
Could NOT find HDF5 (missing: HDF5_LIBRARIES)
I also added the environment variables HDF5_DIR
and HDF5_ROOT
which both point to my HDF5 installation folder C:\Develop\HDF5\1.8.10
.
What am I missing to have CMake recognize the HDF5 installation?
I was using an outdated HDF5 version; the current version is HDF5-1.8.18.
Unfortunately, the VS 2010 x64 generator is missing in the CMake-hdf5-1.8.18 archive. There are only .bat files for VS 2012, 2013 and 2015. It is possible to add other generators though:
HDF5config.cmake
CTEST_CMAKE_GENERATOR
elseif
for your desired generator, i.e. for Visual Studio 2010 x64:elseif(${BUILD_GENERATOR} STREQUAL "VS201064") set(CTEST_CMAKE_GENERATOR "Visual Studio 10 2010 Win64")
build-VS2010-64.bat
HDF5config.cmake file
, i.e.ctest -S HDF5config.cmake,BUILD_GENERATOR=VS201064 -C Release -V -O hdf5.log
.\build\_CPack_Packages\win64
After that I changed the CMakeLists lines shown in the original question, as shown in the
USING_HDF5_CMake.txt
thats created while compilation. Note that I changedC
toCXX
in the component list because I have C++ project.hdf5 can now be installed on Windows via vcpkg (https://github.com/Microsoft/vcpkg)
Jean