Unable to make HDF5 and HDFView work, both at the same time, neither with the .msi HDF5 installation nor with the vcpkg HDF5 installation
14:57 09 Jun 2026

I'm trying to work with HDF5 in a cpp program and also with HDFView (v3.4.1, currently the most recent version).

I'm new with HDF5 and currently I'm trying to work with the next example: h5tutr_crtdat.cpp https://github.com/HDFGroup/hdf5/blob/develop/HDF5Examples/CXX/TUTR/h5tutr_crtdat.cpp


The situation is the next:

Initially I had the .msi HDF5 installation and the project for the h5tutr_crtdat.cpp program was compiling but the HDFView didn't open, showing the error "failed to launch JVM" (already documented as "Known Problems In This Release").

CMakeLists.txt:

cmake_minimum_required(VERSION 3.10.0)
project(test_0 VERSION 1.0 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 23)

enable_testing()

find_package(HDF5 REQUIRED COMPONENTS CXX)
include_directories(${HDF5_INCLUDE_DIRS})

add_executable(${PROJECT_NAME} h5tutr_crtdat.cpp)

target_link_libraries(${PROJECT_NAME} ${HDF5_LIBRARIES} ${HDF5_C_LIBRARIES})

When following one of the documented "solutions" in order to be able to open HDFView: "... removing those directories from the PATH" (removing the HDF5 directory in the "path" of the System Environment Variables), then, HDFView has been able to open (no errors and reading a .h5 file), BUT after this "solution", then the project for the h5tutr_crtdat.cpp program doesn't compile.

So, looking for a way to be able to work with HDF5 and HDFView, the next test has been to keep the previous status (no HDF5 directory in the "path"), and then installing HDF5 from vcpkg and uninstalling the .msi HDF5 general installation, but with the next CMakeLists.txt file, now the cpp project doesn't compile.

CMakeLists.txt:

cmake_minimum_required(VERSION 3.10.0)
project(test_0 VERSION 1.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# find_package(HDF5 REQUIRED COMPONENTS CXX)
find_package(HDF5 COMPONENTS CXX)
# find_package(hdf5 COMPONENTS CXX)
# include_directories(${HDF5_INCLUDE_DIRS})

add_executable(${PROJECT_NAME} h5tutr_crtdat.cpp)

# target_link_libraries(${PROJECT_NAME} ${HDF5_LIBRARIES} ${HDF5_C_LIBRARIES})
target_link_libraries(${PROJECT_NAME} PRIVATE HDF5::HDF5)
# target_link_libraries(${PROJECT_NAME} PRIVATE hdf5::hdf5)

Output:

...
[cmake] -- Could NOT find HDF5 (missing: HDF5_LIBRARIES HDF5_INCLUDE_DIRS CXX) 
[cmake] -- Configuring done (6.4s)
[cmake] CMake Error at CMakeLists.txt:... (target_link_libraries):
[cmake]   Target "test_0" links to:
[cmake] 
[cmake]     HDF5::HDF5
[cmake] 
[cmake]   but the target was not found.  Possible reasons include:
[cmake] 
[cmake]     * There is a typo in the target name.
[cmake]     * A find_package call is missing for an IMPORTED target.
[cmake]     * An ALIAS target is missing.
...

Host Environment:

  • Host: x64-windows
  • Compiler: MSVC 19.50.35729 for x64
  • vcpkg-tool version: 2026-05-27-...
cmake hdf5 vcpkg