Cross Compile on Ubuntu Linux for Windows Using MinGW
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:
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-x86-64 for C language and
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.