Cross compiling for Windows

Dominik Reichardt domiman at
Mon Sep 24 23:35:14 PDT 2012

Am 25.09.2012 um 01:21 schrieb James Linder <jam at>:

> On 25/09/2012, at 3:00 AM, macports-users-request at wrote:
>>> Sorry for the kind of OT post, but can anyone help me get it straight on how to cross compile something for Windows?
>>> I know kind of the last step how to make configure (if there is one) understand that I want to cross compile. I am sucessfully cross compiling for ppc with the old xcode 3.2x stuff but for that everything is pretty much pre set up.
>> The main (and almost the only) thing you need to know is to use
>>   i386-mingw32-gcc / i386-mingw32-g++
>> as the compiler instead of gcc / g++ and you'll get 32-bit windows binaries.
>> However, if you want to cross-compile a complex existing project, it
>> probably won't work out-of-the-box and you would have to carefully
>> modify it. (Cross-compiling for ppc is much easier since Apple
>> supported that well, and one is compiling for the same OS.)
>> One difference is for example that you cannot just run the newly
>> compiled binaries (for windows), but developers may have planted many
>> more eastern eggs into the building chain.
>> Last time when I wanted to cross-compile my own source code, a very
>> small & easy project, I spent a month fighting, just to realize that
>> there was a bug in "ld" and upgrading to a newer version in MacPorts
>> solved the problem.
>>> So what are the steps to cross compile for Windows?
>> The question is probably too generic. It all depends on the type of
>> project and how it's set up to be built. But if you build manually,
>> just using the right compiler (and having the right libraries
>> available?) should be sufficient.
> I guess the answer also depends on weather you want to be kewl and boast that you cross compiled or just get working stuff.
> I run a windoze develepment machine in VBox. That way it is easy to do and you can make use of existing packager tools that are windoze bound.
> That said I make the occasional package for win using Qt that lets me do mac/linux/win from the same source, but I do very little win stuff.

Let's just always assume good things, so it is really about getting working stuff.
For the projects I'm involved in it would be handy to be able to do the occasional compile and quickly test things out. When I was still on Windows three years ago, I had a working mingw/msys setup but that was always breaking left and right, so I'm not that much interrsted to go through the hassle of setting this up in a VM. 


More information about the macports-users mailing list