This is perverse. I’ve just compiled a native Win32 application on Linux. What’s even more perverse it runs on Linux too with Wine.
To cut a long story short I needed a command line tool to send emails using the MAPI protocol, the only language spoken by Outlook and MS Exchange. Don’t ask me why. It’s by the way my first ever Win32 application using the Win32 API. Or `mapi.h’, to be precise.
I started developing it on a Win32-cygwin platform with gcc, but I wanted to control the sources with git. Which prefers Linux. So I ended up rebooting the box a few times to change between the two. But I’m extremely lazy, so I soon googled for a way to cross-compile Win32 programs on a Linux host. It did not take long. I summarize my findings in a few lines:
What to install:
sudo apt-get install mingw32
How to compile:
i586-mingw32msvc-gcc -L/usr/i586-mingw32msvc/lib \ -I/usr/i586-mingw32msvc/include -o foo.exe foo.c
The result? See the mapis page.