Cross compiling hdf5-1.10.4 for Windows with Fortran component

Hello,

I successfully manage to cross compile HDF5 library with Fortran component on my ubuntu 18.04 for Windows, but to do so some fixes were needed.

I just wanted to share this to the community so that it can either be of use to someone else or that some competent person in cross-compiling can point me on what to fix to avoid my problems/error.

My environment is an ubuntu with mingw-w64 installed by packaged and wine64 emulator for execution.
First I needed to patch one file in the source in hdf5-1.10.4/src/H5win32defs.h, on line 57 I had to replace:
__VA_ARGS__
by
##__VA_ARGS__

I had to make a toolchain file which contains this:
SET(CMAKE_SYSTEM_NAME Windows) SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) SET(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) SET(CMAKE_Fortran_COMPILER x86_64-w64-mingw32-gfortran) SET(CMAKE_FIND_ROOT_PATH /home/mozul/WORK/LMGC90/build/windows) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_CROSSCOMPILING_EMULATOR wine64)

Then I configured with this line:
cmake ../../sources/hdf5/hdf5-1.10.4 -DCMAKE_TOOLCHAIN_FILE=../../sources/cmake-mingw64-x86_64 -DCMAKE_INSTALL_PREFIX=../..//install -DHDF5_BUILD_FORTRAN=ON -DBUILD_TESTING=OFF -DHDF5_BUILD_TOOLS=OFF
Once the configure was done there were several files named ‘build.make’ which had to execute some freshly build program on the target platform, but the ‘wine64’ call was either missing or there was missing a space in between the wine call the .exe one. Thus I needed to execute this:
find . -name "build.make" -exec sed -i -e 's/wine64\/home/wine64 \/home/' {} \; find . -name "build.make" -exec sed -i -e 's/\(^.* && \)\(.*\.exe$\)/\1 wine64 \2/' {} \;
Only then could I build it and use the static library generated in my own cross-compiled library.

I wished to join my CMakeCache.txt file for the record but being new here, I am not allowed to do so…

So will this be usefull to someone or is it already fixed in the development version ?

Hello!

Please try to submit your file again. It looks like the new users cannot attach files when they first post on FORUM. If it still doesn’t work, please send us your file for review using Service Desk (help.hdfgroup.org).

Thank you!

Elena

Hello,

Thank you for your answer. I still could not add a file here (I do am a newby here afterall). So I filed a support (SUPPORT-189) has suggested.