Cross compiling for Windows

Mojca Miklavec mojca.miklavec.lists at
Sun Sep 23 22:54:14 PDT 2012

On Sun, Sep 23, 2012 at 11:35 PM, Dominik Reichardt wrote:
> Hi all,
> 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.


More information about the macports-users mailing list