# Cross-compiling for Windows

**URL:** <https://forum.hdfgroup.org/t/cross-compiling-for-windows/6735>\
**Category:** HDF5 Library\
**Created:** [February 27, 2020, 5:41am UTC](https://forum.hdfgroup.org/t/cross-compiling-for-windows/6735 "2020-02-27T05:41:11Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![mose](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/mose/32/1779_2.png) [@mose](https://forum.hdfgroup.org/u/mose)\
**Post date:** [February 27, 2020, 5:41am UTC](https://forum.hdfgroup.org/t/cross-compiling-for-windows/6735/1 "2020-02-27T05:41:11Z")

</div>

Hello, I’m trying to cross-compile HDF5 using [BinaryBuilder](https://binarybuilder.org/), but it’s still not clear to me the setup to use. I’ve tried calling CMake in the following way:

```auto
cmake .. -DCMAKE_INSTALL_PREFIX=${prefix} \
    -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TARGET_TOOLCHAIN} \
    -DHDF5_BUILD_CPP_LIB=OFF \
    -DONLY_SHARED_LIBS=ON \
    -DHDF5_BUILD_HL_LIB=ON \
    -DHDF5_ENABLE_Z_LIB_SUPPORT=ON \
    -DHDF5_ENABLE_SZIP_SUPPORT=OFF \
    -DHDF5_ENABLE_SZIP_ENCODING=OFF \
    -DBUILD_TESTING=OFF

```

but I get the following errors:

```auto
CMake Error: TRY_RUN() invoked in cross-compiling mode, please set the following cache variables appropriately:
   H5_LDOUBLE_TO_LONG_SPECIAL_RUN (advanced)
   H5_LDOUBLE_TO_LONG_SPECIAL_RUN__TRYRUN_OUTPUT (advanced)
For details see /workspace/srcdir/hdf5/build/TryRunResults.cmake
-- Checking IF your system converts long double to (unsigned) long values with special algorithm... no
CMake Error: TRY_RUN() invoked in cross-compiling mode, please set the following cache variables appropriately:
   H5_LONG_TO_LDOUBLE_SPECIAL_RUN (advanced)
   H5_LONG_TO_LDOUBLE_SPECIAL_RUN__TRYRUN_OUTPUT (advanced)
For details see /workspace/srcdir/hdf5/build/TryRunResults.cmake
-- Checking IF your system can convert (unsigned) long to long double values with special algorithm... no
CMake Error: TRY_RUN() invoked in cross-compiling mode, please set the following cache variables appropriately:
   H5_LDOUBLE_TO_LLONG_ACCURATE_RUN (advanced)
   H5_LDOUBLE_TO_LLONG_ACCURATE_RUN__TRYRUN_OUTPUT (advanced)
For details see /workspace/srcdir/hdf5/build/TryRunResults.cmake
-- Checking IF correctly converting long double to (unsigned) long long values... no
CMake Error: TRY_RUN() invoked in cross-compiling mode, please set the following cache variables appropriately:
   H5_LLONG_TO_LDOUBLE_CORRECT_RUN (advanced)
   H5_LLONG_TO_LDOUBLE_CORRECT_RUN__TRYRUN_OUTPUT (advanced)
For details see /workspace/srcdir/hdf5/build/TryRunResults.cmake
-- Checking IF correctly converting (unsigned) long long to long double values... no
CMake Error: TRY_RUN() invoked in cross-compiling mode, please set the following cache variables appropriately:
   H5_DISABLE_SOME_LDOUBLE_CONV_RUN (advanced)
   H5_DISABLE_SOME_LDOUBLE_CONV_RUN__TRYRUN_OUTPUT (advanced)
For details see /workspace/srcdir/hdf5/build/TryRunResults.cmake
-- Checking IF the cpu is power9 and cannot correctly converting long double values... no
CMake Error: TRY_RUN() invoked in cross-compiling mode, please set the following cache variables appropriately:
   H5_NO_ALIGNMENT_RESTRICTIONS_RUN (advanced)
   H5_NO_ALIGNMENT_RESTRICTIONS_RUN__TRYRUN_OUTPUT (advanced)
For details see /workspace/srcdir/hdf5/build/TryRunResults.cmake
-- Checking IF alignment restrictions are strictly enforced... no
-- Warnings Configuration:
-- Could NOT find ZLIB (missing: ZLIB_DIR)
-- Found ZLIB: /workspace/destdir/bin/libz.dll (found version "1.2.11") 
-- Filter ZLIB is ON
-- Found Perl: /usr/bin/perl (found version "5.26.3") 
-- Generating 'H5Epubgen.h'
Generating 'H5Einit.h'
Generating 'H5Eterm.h'
Generating 'H5Edefin.h'

-- Generating '/workspace/srcdir/hdf5/src/H5version.h'

-- Generating 'H5overflow.h'

-- Configuring incomplete, errors occurred!
See also "/workspace/srcdir/hdf5/build/CMakeFiles/CMakeOutput.log".
See also "/workspace/srcdir/hdf5/build/CMakeFiles/CMakeError.log".

```

My understanding was that HDF5 had support for cross-compilation with the CMake build system, but even if I’m passing the CMake toolchain file for the cross-compiler it’s trying to run foreign programs. What should I do?

---

<div class="post-metadata">

**Author:** ![byrn](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/b/85f322/32.png) [@byrn](https://forum.hdfgroup.org/u/byrn)\
**Post date:** [February 27, 2020, 3:04pm UTC](https://forum.hdfgroup.org/t/cross-compiling-for-windows/6735/2 "2020-02-27T15:04:55Z")

</div>

According to CMake, in the cross-compile toolchain you pre-set those variables to the results of the try run. Yes you need to know what those values are. I would start with the info from the CMake sites and go from there.

What version of hdf5 are you building? The most recent versions have improved support for cross-compiling and support a cross-compile executable. I.E. on ubuntu using mingw, I set the program to use wine.

Allen

---

<div class="post-metadata">

**Author:** ![mose](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/mose/32/1779_2.png) [@mose](https://forum.hdfgroup.org/u/mose)\
**Post date:** [February 29, 2020, 2:57am UTC](https://forum.hdfgroup.org/t/cross-compiling-for-windows/6735/3 "2020-02-29T02:57:39Z")

</div>

> [@byrn](#):
>
> According to CMake, in the cross-compile toolchain you pre-set those variables to the results of the try run. Yes you need to know what those values are.

Is there a documentation of what these variables represent? I mean, apart from reading the CMake file and guessing what those variable should be set to by reverse engineering the commands that would need to be run. I thought that the “improved support for cross-compiling” was something less convoluted.

> [@byrn](#):
>
> What version of hdf5 are you building?

[`b49b22d6882d97b1ec01d482822955bd8e923203`](https://bitbucket.hdfgroup.org/projects/HDFFV/repos/hdf5/commits/b49b22d6882d97b1ec01d482822955bd8e923203)

---

<div class="post-metadata">

**Author:** ![mgvisser](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/mgvisser/32/1780_2.png) [@mgvisser](https://forum.hdfgroup.org/u/mgvisser)\
**Post date:** [March 19, 2020, 9:14pm UTC](https://forum.hdfgroup.org/t/cross-compiling-for-windows/6735/4 "2020-03-19T21:14:07Z")

</div>

It would be great if someone could help Mosè along a little bit here. He’s doing this to provide the Julia scientific programming community with consistent builds using [BinaryBuilder](https://binarybuilder.org/). Having a proper HDF5 build would help a great deal for the many Julia packages that rely on the HDF5 library, both directly and indirectly. Thank you!

---

<div class="post-metadata">

**Author:** ![steven](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/steven/32/117_2.png) [@steven](https://forum.hdfgroup.org/u/steven)\
**Post date:** [March 25, 2020, 12:32pm UTC](https://forum.hdfgroup.org/t/cross-compiling-for-windows/6735/5 "2020-03-25T12:32:19Z")

</div>

This is Steven,  
Would it be possible to have a conference call? I am available from 15:00EDT today if that works for you?  
Also I need the details of the stack: versionininfo().  
best: steve

---

<div class="post-metadata">

**Author:** ![mose](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/mose/32/1779_2.png) [@mose](https://forum.hdfgroup.org/u/mose)\
**Post date:** [March 25, 2020, 12:47pm UTC](https://forum.hdfgroup.org/t/cross-compiling-for-windows/6735/6 "2020-03-25T12:47:04Z")

</div>

> [@steven](#):
>
> Would it be possible to have a conference call? I am available from 15:00EDT today if that works for you?

Cool, thanks, yes, I’m available at that time.

> [@steven](#):
>
> Also I need the details of the stack: versionininfo().

The output of `versioninfo()` in my Julia REPL is

```auto
julia> versioninfo()
Julia Version 1.3.1
Commit 2d5741174c (2019-12-30 21:36 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, haswell)

```

Is this what you were asking?

---

<div class="post-metadata">

**Author:** ![steven](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/steven/32/117_2.png) [@steven](https://forum.hdfgroup.org/u/steven)\
**Post date:** [March 25, 2020, 2:59pm UTC](https://forum.hdfgroup.org/t/cross-compiling-for-windows/6735/7 "2020-03-25T14:59:47Z")

</div>

yes. 14:00EDT is good. skype: vargaconsulting.ca google video: [steven.varga@gmail.com](mailto:steven.varga@gmail.com)  
best:  
steve

---

<div class="post-metadata">

**Author:** ![steven](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/steven/32/117_2.png) [@steven](https://forum.hdfgroup.org/u/steven)\
**Post date:** [March 25, 2020, 7:22pm UTC](https://forum.hdfgroup.org/t/cross-compiling-for-windows/6735/8 "2020-03-25T19:22:49Z")

</div>

Mose,  
It was great meeting you! Can we use this download link [https://github.com/steven-varga/hdf5.git](https://github.com/steven-varga/hdf5.git) instead of the official ?

```auto
sources = [
     GitSource("https://bitbucket.hdfgroup.org/scm/hdffv/hdf5.git",
              "b49b22d6882d97b1ec01d482822955bd8e923203"),
]

```

This is to set up a custom pipeline for us to fiddle with, as I have to make some modifications to the HDF5 system. The process is:

1. modify `cmake` + `HDF5` on my laptop
2. upload back to my github HDF5 repository:
3. send pull request against your [Yggrsdrasil/HDF5](https://github.com/giordano/Yggdrasil/tree/cross-compile-hdf5/H/HDF5)
4. check for errors
5. start again or celebrate

Once you OK-d this, we can do a test round - to oil up the cogs, so to speak.

what do you think?  
steve

---

<div class="post-metadata">

**Author:** ![mose](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/mose/32/1779_2.png) [@mose](https://forum.hdfgroup.org/u/mose)\
**Post date:** [March 25, 2020, 9:27pm UTC](https://forum.hdfgroup.org/t/cross-compiling-for-windows/6735/9 "2020-03-25T21:27:28Z")

</div>

Yes, no problem with using it!

---

<div class="post-metadata">

**Author:** ![mafanasiev](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@mafanasiev](https://forum.hdfgroup.org/u/mafanasiev)\
**Post date:** [April 9, 2020, 3:08pm UTC](https://forum.hdfgroup.org/t/cross-compiling-for-windows/6735/10 "2020-04-09T15:08:11Z")

</div>

Hi guys,

Have you made progress w/ the cross-compilation issues? I’m currently trying something similar, attempting to compile for a PowerPC target using an x86 host and the [IBM Advanced Toolchain](https://developer.ibm.com/linuxonpower/advance-toolchain/). Following the snippets above compilation fails quickly with

```auto
.../build/bin/H5detect: cannot execute binary file

```

which I guess is to be expected. I would be grateful for any advice, and am happy to help out if I can.

Mike.

---

<div class="post-metadata">

**Author:** ![steven](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/steven/32/117_2.png) [@steven](https://forum.hdfgroup.org/u/steven)\
**Post date:** [April 9, 2020, 4:46pm UTC](https://forum.hdfgroup.org/t/cross-compiling-for-windows/6735/11 "2020-04-09T16:46:13Z")

</div>

Hi Mike,

according to Allen Byrn the cmake system needs a set of variables pre-defined: [here is the source code](https://github.com/steven-varga/HDFGroup-mailinglist/tree/master/crosscompile-2020-mar-25) to the test programs and a makefile to produce [the macro definitions](https://github.com/steven-varga/HDFGroup-mailinglist/tree/master/crosscompile-2020-mar-25#generated-output)

Once you compiled and ran the test programs on the target architecture, please collect the results and send them to me. (or better: create a ticket on my github page). This is how far I got – other than examined alternative approaches.  
When enough results are collected, it is easy to observe the stationary variables, and the ones which are actually function of the architecture.  
Since I am to do this in my own time, and resources help is always welcome – in any format. Please anyone who reads this, and capable of running the test suite on unusual architecture please help make this happen by submitting the results.

best: steve

---

<div class="post-metadata">

**Author:** ![mafanasiev](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@mafanasiev](https://forum.hdfgroup.org/u/mafanasiev)\
**Post date:** [April 13, 2020, 1:38pm UTC](https://forum.hdfgroup.org/t/cross-compiling-for-windows/6735/12 "2020-04-13T13:38:18Z")

</div>

Hi Steven,

Thanks for the response. We’ve decided in the meantime to compile directly on a cloud instance of a PowerPC machine, primarily for testing purposes. We’re still evaluating this as a final solution though – I’ll ping you if / when we continue down the ppc cross-compilation path.

Cheers.

---

<div class="post-metadata">

**Author:** ![steven](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/steven/32/117_2.png) [@steven](https://forum.hdfgroup.org/u/steven)\
**Post date:** [April 13, 2020, 2:27pm UTC](https://forum.hdfgroup.org/t/cross-compiling-for-windows/6735/13 "2020-04-13T14:27:09Z")

</div>

> [@mafanasiev](#):
>
> cloud instance of a PowerPC machine

Can you please point me to the direction how that works? I work on [H5CPP](http://h5cpp.org), an HDF5 based persistence for modern C++, and would love to have access rental (IAAS) computers of less common architecture for testing purpose.  
best: steve

---

<div class="post-metadata">

**Author:** ![mafanasiev](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@mafanasiev](https://forum.hdfgroup.org/u/mafanasiev)\
**Post date:** [April 13, 2020, 4:26pm UTC](https://forum.hdfgroup.org/t/cross-compiling-for-windows/6735/14 "2020-04-13T16:26:27Z")

</div>

Hi Steven,

Sure. Our company got limited access to a system for porting via the [IBM Power Development Cloud](https://www-356.ibm.com/partnerworld/wps/servlet/ContentHandler/stg_com_sys_power-development-platform).

Best,  
Mike

---

<div class="post-metadata">

**Author:** ![mafanasiev](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/m/439d5e/32.png) [@mafanasiev](https://forum.hdfgroup.org/u/mafanasiev)\
**Post date:** [April 13, 2020, 4:26pm UTC](https://forum.hdfgroup.org/t/cross-compiling-for-windows/6735/15 "2020-04-13T16:26:28Z")

</div>

We additionally also been looking a the [OpenPOWER Foundation](https://openpowerfoundation.org/minicloud-free-openpower-cloud/), and will re-evaluate once we get beyond the deployment stage.

---

<div class="post-metadata">

**Author:** ![steven](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/steven/32/117_2.png) [@steven](https://forum.hdfgroup.org/u/steven)\
**Post date:** [April 13, 2020, 7:04pm UTC](https://forum.hdfgroup.org/t/cross-compiling-for-windows/6735/16 "2020-04-13T19:04:22Z")

</div>

Thanks for the links! I’ve applied for both. If you folks do C++ development you may be interested in my project: [http://isc19.h5cpp.org](http://isc19.h5cpp.org)

best:steve

---

<div class="post-metadata">

**Author:** ![mus-m](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/m/76d3ee/32.png) [@mus-m](https://forum.hdfgroup.org/u/mus-m)\
**Post date:** [April 27, 2020, 4:12am UTC](https://forum.hdfgroup.org/t/cross-compiling-for-windows/6735/17 "2020-04-27T04:12:18Z")

</div>

Hi all, has there been any progress on this front wrt cross-compilation support for Windows and other platforms from cmake?

There is also this half-finished PR [https://github.com/stevengj/hdf5/pull/1](https://github.com/stevengj/hdf5/pull/1)

---

<div class="post-metadata">

**Author:** ![steven](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/steven/32/117_2.png) [@steven](https://forum.hdfgroup.org/u/steven)\
**Post date:** [April 27, 2020, 4:57am UTC](https://forum.hdfgroup.org/t/cross-compiling-for-windows/6735/18 "2020-04-27T04:57:25Z")

</div>

Hi, thanks for the interest. I am aware of [Steven’s](https://github.com/stevengj) work. The progress is slow, as I need the output [of this program](https://github.com/steven-varga/HDFGroup-mailinglist/tree/master/crosscompile-2020-mar-25) executed on various platforms.

best: steve

---

<div class="post-metadata">

**Author:** ![mus-m](https://forum.hdfgroup.org/letter_avatar_proxy/v4/letter/m/76d3ee/32.png) [@mus-m](https://forum.hdfgroup.org/u/mus-m)\
**Post date:** [September 17, 2020, 2:32am UTC](https://forum.hdfgroup.org/t/cross-compiling-for-windows/6735/19 "2020-09-17T02:32:24Z")

</div>

Which program exactly and which platforms should we post the output for? I have a Windows machine I can post the output of and I’m sure I can ask for other platforms, so we can help support this process.

---

<div class="post-metadata">

**Author:** ![steven](https://forum.hdfgroup.org/user_avatar/forum.hdfgroup.org/steven/32/117_2.png) [@steven](https://forum.hdfgroup.org/u/steven)\
**Post date:** [September 17, 2020, 3:30am UTC](https://forum.hdfgroup.org/t/cross-compiling-for-windows/6735/20 "2020-09-17T03:30:13Z")

</div>

The more the better, as far as I recall a conversation with Allen Byrne cmake version is the more promising way to go. There are a set of cmake variables need to be set, downloading [this source](https://github.com/steven-varga/HDFGroup-mailinglist/tree/master/crosscompile-2020-mar-25) then executing `make` the list is printed with the correct values for **your system** , which is the target.

You need to have these values for all target platforms. In my understanding the HDF5 `cmake` and `configure` executes two programs: [ConversionTests.c](https://github.com/steven-varga/HDFGroup-mailinglist/blob/master/crosscompile-2020-mar-25/ConversionTests.c), [HDFTests.c](https://github.com/steven-varga/HDFGroup-mailinglist/blob/master/crosscompile-2020-mar-25/HDFTests.c) with various `-Dxyz` macros defined, and statistics collected. The provided make file mimics this behaviour and collects the statistics for you.

In a different phase, using the [collected statistics](https://github.com/steven-varga/HDFGroup-mailinglist/tree/master/crosscompile-2020-mar-25#generated-output) and a modified/updated `cmake` script one should be able to cross compile to given target.

Analysing the statistics one could possibly simplify the procedure, without dire consequences, but that is only a hunch. Also note as months go by, all that readings I did half year ago is slowly evaporating, so I could be slightly or entirely wrong and your new compiler tool chain will be choking on zeros and ones.

best wishes:  
steven  
vargaconsulting
