HDF5 IFX Fortran Static LIB in Windows (VS or Terminal)

Hi everyone,

I’m having trouble creating static libraries for FORTRAN to compile programs with HDF5 on Windows (using either the terminal or VS2022). While I had success on Linux, Windows has been quite challenging for me.

Here’s what I’ve done so far, following the instructions in the “INSTALL_CMake.txt” file:

  1. Created a directory for HDF5.
  2. Downloaded the necessary files: CTestScript.cmake, HDF5config.cmake, HDF5options.cmake, zlib-1.3.tar.gz, libaec-1.0.6.tar.gz, and hdf5-1.14.4-3.zip.
  3. Modified HDF5options.cmake to enable FORTRAN.
  4. Opened the “Intel oneAPI command prompt for Intel 64 for Visual Studio 2022”.
  5. Executed the following command:
ctest -S HDF5config.cmake,BUILD_GENERATOR=VS202264 -C Release -VV -O hdf5.log

The configuration went smoothly, generating a BUILD folder containing a zip file. After unzipping, I found the FORTRAN includes in the mod folder and the static libraries in the lib\static folder.

In VS2022, I created a new project and provided the paths for the includes and static libraries as instructed in the “USING_HDF5_VS.txt” file. However, when I tried to compile (in both release and debug modes), I encountered errors during the linking stage.

I also tried manually compiling the code in the terminal without success. The object files are generated (for both debug and release options), but linking the static libraries results in several errors.

I’m completely lost at this point. I’ve searched many sources and forums, found similar issues, but no solutions that work for me.

Here are some of my attempts and the errors:

Compiling stage:
Using ifx:

For the compiling stage, I was able to create the object file without any problems…
Now for the linking stage:

Using ifx:


here are the error…
linkingError.txt (66.6 KB)

Using ifort, same error from ifx… I tried both compilers because I was worried that I build with the wrong compiler… And I did not find any options to set the preferable compiler.

Also tried to combine all the static libraries provided… No success…

Any help or suggestions would be greatly appreciated!

Ivan

Hi, @ivan.moraes !

You may want to look at how we CI:

hdf5/.github/workflows/intel-cmake.yml at develop · HDFGroup/hdf5

Your Intel oneAPI is the latest one.
Our CI uses 2024.1.
Thus, it could be the reason.

Feel free to test with our develop branch and submit an issue on GitHub
if it still doesn’t work with Intel oneAPI 2024.2.1.

1 Like

Hi @hyoklee!

Thank you for your quick reply!

I was checking the version as you suggested, but I think is something that I’m doing wrong, because on Linux I have built the same version as I’m trying on Windows and everything went fine!

The example FORTRAN and a Makefile for my test that worked fine:
noMansLand.f90 (983 Bytes)
noMansLand.mak (1.1 KB)

Here’s what I did on Linux:

This is the source that I use to build the HDF5.
image

Here is my oneApi version:

On Linux, I followed some instructions that you provided in another post (It helped a lot! Thank you!).

I use make in the hdf5-1.14.4-3 folder with these commands:

CC=/opt/intel/oneapi/compiler/2024.2/bin/icx FC=/opt/intel/oneapi/compiler/2024.2/bin/ifx ./configure --prefix=/usr/local/hdf5 --enable-fortran
make -j
make check -j
sudo make install

Pardon my inexperience with the make file, but it is possible to replicate exactly this command on the windows? Or what I did in my previous post is already the Windows way?

I’m not familiar with the .ylm file, but I tried to read what were the steps for building. But I was not successful. So I tried to build the same way as I did for the last release, but it failed.

I could not understand what was the cause, here is the log if helps.
hdf5.log (18.0 KB)

In the meantime, I’m going to try the downgraded oneApi and see if it goes well!

Thanks for the support!

Cheers

Ivan Santos

HI, @ivan.moraes !

Thanks for sharing the log file.

  1. Install perl. (e.g., Strawberry Perl).
  2. Install Ninja.
  3. Use “-G Ninja” in cmake configuration.
  4. Disable all compressions.

Here’s a sample cmake configuration:

cmake -G Ninja -DCMAKE_C_COMPILER="C:/Program Files (x86)/Intel/oneAPI/compiler/latest/bin/icx.exe" -DCMAKE_CXX_COMPILER="C:/Program Files (x86)/Intel/oneAPI/compiler/latest/bin/icpx.exe" -DCMAKE_Fortran_COMPILER="C:/Program Files (x86)/Intel/oneAPI/compiler/2024.2/bin/ifx.exe"  -DBUILD_SHARED_LIBS:BOOL=ON  -DHDF5_BUILD_FORTRAN:BOOL=ON   -DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=OFF -DHDF5_ENABLE_SZIP_SUPPORT:BOOL=OFF -DHDF5_ENABLE_SUBFILING_VFD:BOOL=OFF 
-DHDF5_BUILD_FORTRAN:BOOL=ON  ..

You don’t have to downgrade Intel oneAPI 2024.2.
I tested it today with fortran and it worked fine on develop branch of HDF5.
There’s 1 test error though:

https://my.cdash.org/viewTest.php?onlyfailed&buildid=2661073

Once you could start building successfully, you can enable other compression one by one.

1 Like

Hi, @hyoklee!

I followed your suggestions and managed to build the project, but I’m still facing issues with compiling the program.

After installing PERL and NINJA, I was able to build the project as per your instructions. Here’s what I did:

  1. Downloaded the development build from Git and unzipped it to the hdf5-develop folder.
  2. Created a build folder inside the hdf5-develop directory.
  3. Opened the build folder in an Intel oneAPI terminal with the environment variables for FORTRAN loaded.

Then, I executed the following command:

> cmake -G Ninja -DCMAKE_C_COMPILER="C:/Program Files (x86)/Intel/oneAPI/compiler/latest/bin/icx.exe" -DCMAKE_CXX_COMPILER="C:/Program Files (x86)/Intel/oneAPI/compiler/latest/bin/icpx.exe" -DCMAKE_Fortran_COMPILER="C:/Program Files (x86)/Intel/oneAPI/compiler/2024.2/bin/ifx.exe"  -DBUILD_SHARED_LIBS:BOOL=ON  -DHDF5_BUILD_FORTRAN:BOOL=ON   -DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=OFF -DHDF5_ENABLE_SZIP_SUPPORT:BOOL=OFF -DHDF5_ENABLE_SUBFILING_VFD:BOOL=OFF 
> -DHDF5_BUILD_FORTRAN:BOOL=ON  ..

Here’s the log:
config.log (9.4 KB)

After configuring, I used the following command to build the project as per the .yml file from your previous post:

cmake --build .  

Everything seemed fine in the terminal, with only some warnings that I don’t think are problematic. Here’s the log:
build.log (235.0 KB)

In the build folder, I found the static libraries for FORTRAN at:

~\hdf5-develop\build\mod\static

The .lib files were not in a specific folder, so I searched and found several files with the .lib extension. I guessed that static libraries start with lib , so I listed files that start with lib and have the .lib extension. Here are the ones I found:

I’m confused by the file terminology, especially the “hl” and “_D” in the file names. I decided to use the following files:

  • libhdf5_D.lib
  • libhdf5_fortran_D.lib

The compilation with the path to the static library worked fine, and I was able to generate the .obj file. However, the linking stage failed. I’m not sure if I’m linking correctly.

Here’s my linking command:

ifx hdf5Master.obj -o hdf5Master.exe /link "C:\Users\ivanm\Downloads\HDF5_Hyoklee\hdf5-develop\build\bin\libhdf5_D.lib" "C:\Users\ivanm\Downloads\HDF5_Hyoklee\hdf5-develop\build\bin\libhdf5_fortran_D.lib"

Here’s the linking log:
linking.log (237.0 KB)

There are many library conflicts, and I’m not sure why. Any help would be greatly appreciated!

Thanks!

PS: I tried changing the lib files, from all the options that I found… but no success.

Hi, @ivan.moraes !

Thank you for testing further with your custom application.

Can you try the new release candidate:

https://support.hdfgroup.org/releases/hdf5/v1_14/v1_14_5/downloads/snapshot-1.14.5-win-vs2022_intel.msi

Once you installed it, please take a look at

C:\Program Files\HDF_Group\HDF5\1.14.5\HDF5Examples\FORTRAN

as a reference for building your own application.

Regards,

Hello, @hyoklee!

I installed the .msi file and used one of the examples provided in the folder you pointed out.

I chose a simple FORTRAN example for creating groups:

C:\Program Files\HDF_Group\HDF5\1.14.5\HDF5Examples\FORTRAN\H5G\h5ex_g_create.F90

I created a VS2022 project and added the example file:

Then, I configured the project settings for HDF5:

I tried to compile both for release and debug, but was unsuccessful:

Thanks again for all the support!

Ivan

Windows also needs the shwlapi system library to satisfy the StrStrIA symbol

1 Like

As stated in the documentation file, USING_HDF5_VS.txt (see the share installation folder) you will need to add H5_BUILT_AS_DYNAMIC_LIB to the Preprocessor Definitions.

This is for the static libraries also?

Thanks!

Thanks! Do you know where can I find this lib?

Cheers!

A quick search indicates it is in the “Windows Kits” and that simply adding shwlapi.lib to additional dependicies should work.

1 Like

Hi @byrn, @hyoklee,

I wanted to share that I successfully compiled the program using the shared library, following @byrn’s recommendations!

While using shared libraries isn’t my preferred option, it works for now in the Windows environment. I plan to try static libraries in the future.

Thank you both so much for your support!

Cheers,
Ivan

1 Like

Static should also work but see the USING_HDF5_VS.txt doc for the extra libs needed for static linking,
Note that static builds still use dynamic system libraries (shlwapi, C runtime).