Marc Wäckerlin
Für eine libertäre Schweiz

Cross Compile on Ubuntu Linux for Windows Using MinGW

May 7, 2014

Cross Compiling on a Linux (Ubuntu) for Windows targets has become really simple in the last years. Some time ago, I had to do a lot of tricks, including copying DLLs from a Windows system and converting them for use with MinGW. But now, all the tricks and hacks have gone, cross-compilation is very simple. This is my first example of a 3rd-party library. Next article will talk about cross compiling OpenSSL.

The general way to cross compile is extremely simple, as long as the programmer was smart enough to use the GNU Auto-Tools:

./configure --host=i686-w64-mingw32
make

There is a cross compiler target for 32bit, named  i686-w64-mingw32 and one for 64bit, named x86_64-w64-mingw32. They are in the Ubuntu packages gcc-mingw-w64-i686 and gcc-mingw-w64-x86-64 for C language and g++-mingw-w64-i686 g++-mingw-w64-x86-64 for C++. You will also need to install the binutils in package binutils-mingw-w64. To setup a Windows cross compile environment on Linux, just call sudo apt-get install mingw-w64, this installs all you need and much more. Then you are ready for the next article.

Kommentare

[…] on 32bit or 64bit Windows. After you have set up your cross compile environment as described in my previous article, you are now ready to start compiling for example OpenSSL, which is a requirement for Qt5 that will […]