Hdf5_java.dll: The specified procedure could not be found

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);
		}
       }
}

The command line used:

java -Xmx1024M -Djava.library.path="C:\Program Files\HDF_Group\HDF5\1.14.3\bin" -cp ".;C:\Program Files\HDF_Group\HDF5\1.14.3\lib/jarhdf5-1.14.3.jar;C:\Program Files\HDF_Group\HDF5\1.14.3\lib/slf4j-api-2.0.6.jar;C:\Users\david\.m2\repository\ch\qos\logback\logback-classic\1.3.6\logback-classic-1.3.6.jar;C:\Workspaces\tests\java\HDF_test\target\HDF_test-1.0-SNAPSHOT.jar" -Dhdf.hdf5lib.H5.loadLibraryName=hdf5_java -ea org.example.Main

What can be the problem here?

UnsatisfiedLinkError is typically a missing library or incorrect path. With Windows you need to add the bin folder to the PATH.

That’s not it. I have the HDF5 bin folder in the Path already.

Have you tried the examples provided from the install? Just follow the USING_examples.txt file and be sure to enable the java option.

Well the result is dismal, 101 tests failed out of 156
test.log (25.4 KB)

The command to run the tests:

ctest -S HDF5_Examples.cmake,INSTALLDIR=install_dir,HDF_BUILD_JAVA=ON  -C Release -V -O test.log

But the good news is that it isn’t only a java issue, it is not finding the HDF5 library.

Can you rerun but change the -V to -VV

Here it is
test.log (170.8 KB)

Good: – HDF5-1.14.3 found: INC=C:/Program Files/HDF_Group/HDF5/1.14.3/include; TOOLS=C:/Program Files/HDF_Group/HDF5/1.14.3/bin

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.

Here is the PR that fixed it: Include shlwapi.h explicitly on Windows by mkitti · Pull Request #2407 · HDFGroup/hdf5 · GitHub

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)

1 Like

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)

1 Like

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

– HDF5-1.14.5 found: INC=C:/Program Files/HDF_Group/HDF5/1.14.5/include; TOOLS=C:/Program Files/HDF_Group/HDF5/1.14.5/bin
– HDF5 link libs: hdf5::hdf5-shared Includes: C:/Program Files/HDF_Group/HDF5/1.14.5/include
– HDF5 link libs: hdf5::hdf5-shared
– HDF5 H5_LIBVER_DIR: 114 HDF5_VERSION_MAJOR: 1.14

configure thinks it is getting the correct versions

Yes, somehow it is loading the 1.12 hdf5 library instead of the 1.14.5

Definitely a system path issue - somewhere there is a path var causing the problem.

Finally, it works.

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…