Dealing with MinGw cross compiler

Since i’m working on an open-source project to provide easy-to-use asynchronous network I/O framework, and with the aim to make this project as portable as possible, i had to deal with building a cross-compiler for Windows platform, and i’m sorry to say that it wasn’t an «out-of-the-box» task.

When i first started this, i tried to use Mingw, but their website was just hacked the same time i needed it, so back on google, where i found w64 cross compiler project. The documentation was quite easy to follow, and it took me around 1 day to get it working.

I followed theses instructions with an half success. Actually, they are saying that we can build a multilib compiler, but i found out that only the 32 bits compiler was able to build. For the multilib, it fails to build because of incompatible registers name in the early stage 1 of gcc. Also, i wanted to use JNI interface without the need to uses a JDK (mostly because JNI headers are not located in standard locations, for instance with Gentoo, it was under /opt), so i needed to build the GCJ compiler, which is mostly a pain in the ass ! First of all, it seems the cross-compiling is very difficult to reach, mostly because it seems there is no maintainers for the Makefiles, for example, compiling ecjx.exe fails with original sources, as it is trying to build it with the cross compiler, instead of the host’s one. Fixing it was not easy, but i manage to get it to work.

Well, after some time tweaking the Makefiles by myself, i finally got my w64-mingw32 gcc 4.6.0 compiler, and it’s working like a charm. I managed to use most of win32 API without any problem, except that for Condition Variables, i had to take the mingw trunk crt.

So if some of you needs help to develop portable applications for both Win32 and Linux, i am now able to point you things out 😉

In a future article, i will try to describe the steps to have a fully working i686-w64-mingw32-{gcc,ecj} toolchain, so see you soon !

Leave a Comment