I’m using the latest compiled release of HDF5 library (1.14.3) on Windows. Even for an elementary Java test program, the program fails with the following error:
java.lang.UnsatisfiedLinkError: C:\Program Files\HDF_Group\HDF5\1.14.3\bin\hdf5_java.dll: The specified procedure could not be found
The program:
package org.example;
import hdf.hdf5lib.*;
public class Main {
public static void main(){
long fileId = -1;
try {
// Open file
fileId = H5.H5Fopen("", HDF5Constants.H5F_ACC_RDONLY, HDF5Constants.H5P_DEFAULT);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
COMMAND Result: Exit code 0xc0000409 usually means that a dll was not found that it needs.
I think this might be the shlwapi dll issue. We fixed this in 1.14.5 - I believe.
but you can get around this by editing the hdf5-targets.cmake file and adding shlwapi to the hdf5-shared INTERFACE_LINK_LIBRARIES line. I’m searching the forum/GH for where that workaround was shown. (Or use 1.14.5)
Another workaround is to add it to your apps target_link_libraries:
add_executable(target ${SOURCE_FILES})
include_directories(${HDF5_INCLUDE_DIR})
target_link_libraries(target ${dependent_libraries} shlwapi)
I’ve just tried the new version (1.14.5), but most of the tests are not passing: test.log (649.3 KB)
The problem seems to be that the hdf version installed in vcpkg is used for some reason. But this should not happen, it is not on the path and I did not set up the vcpkg toolchain for the ctest…
52: – Error Output :
52: Warning! HDF5 library version mismatched error
52: The HDF5 header files used to compile this application do not match
52: the version used by the HDF5 library to which this application is linked.
52: Data corruption or segmentation faults may occur if the application continues.
52: This can happen when an application was compiled by one version of HDF5 but
52: linked with a different version of static or shared HDF5 library.
52: You should recompile the application or check your shared library related
52: settings such as ‘LD_LIBRARY_PATH’.
52: You can, at your own risk, disable this warning by setting the environment
52: variable ‘HDF5_DISABLE_VERSION_CHECK’ to a value of ‘1’.
52: Setting it to 2 or higher will suppress the warning messages totally.
52: Headers are 1.14.5, library is 1.12.1
Looks like the build is picking up the wrong version for the headers
The problem was really a different version of the HDF library on the PATH. The reason why it took me so long to resolve is that the ctest misreports the path to the library in the logs. It logs the location where the library was compiled, not the path to the file. The actual file that caused the problem is on a completely different path (Which is in PATH, unlike vcpkg…)
After that, all tests pass, and the error in my test example is gone as well.
Thank you for guiding me in the right direction! I think I would never solved this without the provided tests…