Cross-building Windows binaries using the mingw toolchain

Florian Weimer fweimer at
Wed Apr 30 16:31:24 UTC 2014

On 04/30/2014 06:16 PM, Volker Simonis wrote:

> The first one is to make the OpenJDK compile on Windows with the MinGW
> toolchain (instead of Cygwin). This currently doesn't work out of the
> box but is relatively easy to achieve (see for example "8022177:
> Windows/MSYS builds broken"
> Magnus and I are
> working on this (and actually I have an internal build which works
> with MinGW). Hopefully we can fix this in the OpenJDK soon.

Thanks for your input.  If you say "MingW toolchain", you mean the 
scripting environment, but not the compiler and linker, right?

> The second one is to cross compile the whole OpenJDK on Linux using
> gcc and MingGW. If I understood you right that's what you actually
> wanted.

Yes, that's what I'm interested in.

 > I personally think that would be nice to have but at the same
> time I also think it would be quite hard to get there and probably not
> worth doing it because even if you'd succeed nobody will probably
> maintain it and it would break quite soon (see for example the
> GCC/Solaris build or the Clang/Linux build).

It's clear to me that this is worthwhile only if I set up a builder 
which detects bit rot quickly.

> If you want to try it nevertheless, some of the problems you will face
> will be at least the following ones:
> - convert the HotSpot nmake makefiles to GNU syntax (notice that this
> project is currently underway under the umbrella of the new build
> system anyway, so you'd probably want to wait to avoid doing double
> work)

Ah, interesting.

> - convert Visual Studio intrinsics, inline assembler and compiler
> idiosyncrasies to GCC syntax

Ahh, I wonder how much I will encounter there.  That would be 
prerequisite for a pure-mingw build on Windows as well, right?

> - you'll probably also need to cross compile dependencies like
> libfreetype with GCC/MinGW

Fedora already covers those, although the paths are somewhat unexpected.

> - I'm actually not an expert, but the OpenJDK is linked against some
> native Window libraries like DirectX and runtime libraries from the
> Microsoft SDKs. I'm not an expert here and I don't know how that would
> work for a cross-compile.

We supposedly have the headers and import libraries in Fedora.

> I personally think we should rather focus on further improving the
> current Windows build. It's already a huge improvement compared to the
> old JDK7 Windows build. From what I see, the main remaining problems
> are to somehow make it possible to get a stable, defined and free
> version of the Microsoft development tools which are "known to work".

Yes, I tried to set up a Windows development environment, but quickly 
got confused.

My background here is that I want to contribute some new features and I 
expect that feature parity for Windows will increase the likelihood of 

I need to think about it, but for my purposes, a pure mingw environment 
running on Windows would work as well.  It would be less specialized, so 
perhaps there is more interest in that.

Florian Weimer / Red Hat Product Security Team

More information about the build-dev mailing list