Unresolved external symbol __imp_StrStrIA

I am trying to build a 64bit Fortran HDF5 application using the 1.14.2 version of the API on Windows. I ran the build-VS2019-64.bat file. The only change I made was in HDF5options.cmake file to enable Fortran.

The API was compiled without any issue. But when I try to link my application against the static libraries I get the following error:

libhdf5.lib(H5system.obj) : error LNK2019: unresolved external symbol __imp_StrStrIA referenced in function Wstrcasestr_wrap

Also note that my application was previously linked to the 1.12.2 version of the HDF5 API successfully. How can I resolve this issue? Any help would be greatly appreciated.

Might be related to Github issue: The cmake configuration should provide transitive dependencies (like shlwapi on MSVC) #3663

Does this mean there is a bug in HDF5 code distribution? Is there a workaround?

I am having trouble reproducing this issue in current develop branch. Using a binary with the included examples and requesting to use static libraries, I do not see this error.
I also tried 1.14 develop branch and did not see this error.

I guess I need more info (not sure what) to reproduce this.

I uploaded a zip file to Box that hopefully will reproduce the issue. The file is a bit large; I didnā€™t want to exclude anything from the HDF5 build folder.

My workflow was:

  1. Run build-VS2019-64.bat to create the 64bit Release static libraries. I use cmake 3.25.1.
  2. Open Fortran_LinkerError.sln file in VS 2019 and compile. I use latest version of Intel Fortran (oneAPI 2023.2.1.7)

Hopefully, this is enough info to reproduce the issue.

same problem here:
Link: executing ā€˜C:\PROGRA~2\Intel\oneAPI\compiler\20231~1.0\windows\bin\Intel64....\bin-llvm\lld-link.exeā€™
lld-link: error: undefined symbol: __declspec(dllimport) StrStrIA

referenced by libhdf5.lib(H5system.obj):(Wstrcasestr_wrap)
Any update on this?

The hdf5 library needs this on windows, 1.14.2 may be missing this requirement in the generated CMakeConfig files, which the newer versions should now include.

1 Like

Dear member of hdf group,

unfortunately I also got the problem described here with Version 1.14.4.3

So, when and in which commit was this being fixed yet?
I canā€™t see any comment within the release notes directly or in the commits so far.

Please give me detailed description how to fix it if it isnā€™t in the code yet.

Thanks and Greetings,

Daniel

So we did add the lib requirement for shlwapi, however it looks like CMake or our use of CMake only added the requirement to the static library.
See the installed cmake folder and the hdf5-targets.cmake and check the INTERFACE_LINK_LIBRARIES lines for the hdf5 library.

Try adding the shlwapi part to the shared library line and see if that solves your problem.
We will investigate why, but it would help to know if it fixes your problem.

Which line did you mean exactly for ā€œshared libraryā€?
I see 3 entries with INTERFACE_LINK_LIBRARIES.

Every library target should have that property.
set_target_properties(hdf5::hdf5-shared PROPERTIES
should be the one to add the property,
set_target_properties(hdf5::hdf5-static PROPERTIES
should have the property.

Allen

Hey Allen,

I was first wondering where the shared should be. But then Iā€™ve recognized that Iā€™m building with shared libs off in cmake.

Building with shared ON and your fix in the cmake target it runs now flawlessly.
Thanks for the help and I hope this comes into a future version then.

Daniel

1 Like

EDIT: Sorry I meant to reply to Daniel.

Hi Daniel,

I was just running into this issue last night and Iā€™m not sure I follow on how you were able to resolve it. Can you elaborate on your solution?

Cheers,

Gabe

This problem is related to shlwapi.lib on Windows mentioned by byrn.
In my case, in CMakeLists.txt, I add the following lineā€¦

add_executable(target ${SOURCE_FILES})
include_directories(${HDF5_INCLUDE_DIR})
target_link_libraries(target ${dependent_libraries} shlwapi)