Repository navigation
Description
Hi,
I have encountered a problem building HDF5 version 2.2.0 from source on Windows using the Visual Studio compiler. It seems to be related to generating a libh5lz4.dll file. I have the full cmake output, if required.
Thanks,
Alex
Describe the bug
The HDF5 library version 2.2.0 fails to build on Windows using the recommended preset.
Expected behavior
That the library should build.
Platform
- HDF5 version 2.2.0
- Windows 11 Enterprise 25H2
- Compiler: Visual Studio Community Edition 2026, version number 18.9.0 (18.8.2 also failed), and Visual Studio Community Edition 2022 version 17.14.38
- CMake 4.4.1
- Ninja 1.13.2
- Java 26.0.2 (build also fails if Java is not present)
- Note the plugin sources were not downloaded separately - the build process did that.
Additional context
I ran this command from the Visual Studio 2026 Developer PowerShell command line, as recommended in the INSTALL_CMake.md file:
cmake --workflow --preset ci-StdShar-MSVC --fresh
Command and error from the VS 2026 18.9.0 compiler. The other versions of the compiler give essentially the same error, but have different build artifact numbers.
[3734/4111] C:\windows\system32\cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_dll --msvc-ver=1951 --intdir=_deps\hdf5_filter_plugins-build\LZ4\src\CMakeFiles\h5lz4.dir --rc="C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x86\rc.exe" --mt="C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x86\mt.exe" --manifests -- "C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.51.36231\bin\Hostx86\x86\link.exe" /nologo _deps\hdf5_filter_plugins-build\LZ4\src\CMakeFiles\h5lz4.dir\H5Zlz4.c.obj /out:bin\libh5lz4.dll /implib:bin\libh5lz4.lib /pdb:bin\libh5lz4.pdb /dll /version:0.0 /machine:X86 /debug /INCREMENTAL bin\hdf5.lib bin\lz4.lib ws2_32.lib shlwapi.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && C:\windows\system32\cmd.exe /C "cd /D C:\sources\myhdfstuff\build\ci-StdShar-MSVC\_deps\hdf5_filter_plugins-build\LZ4\src && "C:\Program Files\CMake\bin\cmake.exe" -E copy_if_different C:/sources/myhdfstuff/build/ci-StdShar-MSVC/bin/libh5lz4.dll C:/sources/myhdfstuff/build/ci-StdShar-MSVC/plugins/libh5lz4.dll""
FAILED: [code=4294967295] bin/libh5lz4.dll
C:\windows\system32\cmd.exe /C "cd . && "C:\Program Files\CMake\bin\cmake.exe" -E vs_link_dll --msvc-ver=1951 --intdir=_deps\hdf5_filter_plugins-build\LZ4\src\CMakeFiles\h5lz4.dir --rc="C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x86\rc.exe" --mt="C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x86\mt.exe" --manifests -- "C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.51.36231\bin\Hostx86\x86\link.exe" /nologo _deps\hdf5_filter_plugins-build\LZ4\src\CMakeFiles\h5lz4.dir\H5Zlz4.c.obj /out:bin\libh5lz4.dll /implib:bin\libh5lz4.lib /pdb:bin\libh5lz4.pdb /dll /version:0.0 /machine:X86 /debug /INCREMENTAL bin\hdf5.lib bin\lz4.lib ws2_32.lib shlwapi.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && C:\windows\system32\cmd.exe /C "cd /D C:\sources\myhdfstuff\build\ci-StdShar-MSVC\_deps\hdf5_filter_plugins-build\LZ4\src && "C:\Program Files\CMake\bin\cmake.exe" -E copy_if_different C:/sources/myhdfstuff/build/ci-StdShar-MSVC/bin/libh5lz4.dll C:/sources/myhdfstuff/build/ci-StdShar-MSVC/plugins/libh5lz4.dll""
LINK Pass 1: command "C:\Program Files\Microsoft Visual Studio\18\Community\VC\Tools\MSVC\14.51.36231\bin\Hostx86\x86\link.exe /nologo _deps\hdf5_filter_plugins-build\LZ4\src\CMakeFiles\h5lz4.dir\H5Zlz4.c.obj /out:bin\libh5lz4.dll /implib:bin\libh5lz4.lib /pdb:bin\libh5lz4.pdb /dll /version:0.0 /machine:X86 /debug /INCREMENTAL bin\hdf5.lib bin\lz4.lib ws2_32.lib shlwapi.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:_deps\hdf5_filter_plugins-build\LZ4\src\CMakeFiles\h5lz4.dir/intermediate.manifest _deps\hdf5_filter_plugins-build\LZ4\src\CMakeFiles\h5lz4.dir/manifest.res" failed (exit code 1120) with the following output:
Creating library bin\libh5lz4.lib and object bin\libh5lz4.exp
H5Zlz4.c.obj : error LNK2019: unresolved external symbol _htonl referenced in function _H5Z_filter_lz4
H5Zlz4.c.obj : error LNK2019: unresolved external symbol _ntohl referenced in function _H5Z_filter_lz4
bin\libh5lz4.dll : fatal error LNK1120: 2 unresolved externals
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Effort
Projects
- StatusShow more project fieldsDone
Activity
jhendersonHDF commentedon Aug 18, 2026
Hi @AlexHenderson,
is there anything you can think of that might be out of the ordinary for your setup? We test this preset in a daily build workflow https://github.com/HDFGroup/hdf5/actions/runs/31853394062/job/94933868196, which uses Windows Server 2025 and VS Enterprise 18.8.12023.21. For comparison, here's the matching link command in that run:
Outside of paths, the only difference appears to be the machine type,
/machine:x64vs./machine:x86. That said, we don't test on 32-bit Windows.AlexHenderson commentedon Aug 19, 2026
Hi @jhendersonHDF , Thanks for getting back to me.
Curious you mention x86. I can see there is a
/machine:x86flag in the command I copied from the cmake output. The PC I'm using is x64, so I don't know where the x86 command comes from. I can see why that might throw an error at the linking stage though. However, I'm using the cmake preset provided by HDF, so I would have expected that to detect the hardware appropriately. The laptop is an Intel Core Ultra 7 255U (2.00 GHz), which has some funky cores, although I can't see that causing a problem. 16 GB RAM if that matters.I'll stand up a VM with the same OS and software, to see if it behaves differently. It could be something my organisation has blocked/enabled.
Thanks, Alex
jhendersonHDF commentedon Aug 19, 2026
It's also possible that CMake might just be defaulting to using x86 for some reason. Since using presets doesn't allow specifying of any other options to override defaults, we might need to create separate presets that specify the CMAKE_GENERATOR_PLATFORM directly.
AlexHenderson commentedon Aug 23, 2026
Thanks @jhendersonHDF for pointing me in the right direction. It is indeed a matter of the machine architecture.
Building on the command line using Visual Studio requires a bunch of environment variables to be injected into either a Command Prompt, or PowerShell instance. VS has shortcuts to batch files that do that for you. It even creates shortcuts on the Start Menu for you. However, these shortcuts: 'Developer Command Prompt for VS' and 'Developer PowerShell for VS' point to versions of Command Prompt and PowerShell with environment variables indicating the host and target architecture to be 32-bit. Thanks Microsoft.
The environment variables in question appear to be
VSCMD_ARG_HOST_ARCHandVSCMD_ARG_TGT_ARCH. The shortcuts above set these tox86. I assume this is what cmake finds, and assumes we want a 32-bit version of HDF5, which doesn't build.I am running Terminal. VS appears to add profiles to Terminal called 'Developer Command Prompt for VS 18' and 'Developer PowerShell for VS 18'. Note the addition of the '18' to the string. These versions of Command Prompt and PowerShell inject the
VSCMD_ARG_HOST_ARCHandVSCMD_ARG_TGT_ARCHenvironment variables set tox64. Now HDF5 builds fine.More information and other Start menu shortcuts here: https://learn.microsoft.com/en-us/cpp/build/building-on-the-command-line?view=msvc-180 (select your version of MSVC from the left hand menu).
So, in short, it was an issue at my end. I hope this post gives other users enough information to solve similar problems.
This ticket can now be closed.
jhendersonHDF commentedon Aug 24, 2026
Thanks for the update @AlexHenderson. It could probably be stated better in documentation somewhere, but we currently only do very minimal testing on 32-bit Ubuntu as a quick check rather than being officially supported. And in that CI build we turn off support for the feature which you ran into problems with.