20.8.08

Howto: Cross-Compile stuff in Linux for Windows

So, I've learned something else nerdy (regular readers can skip this if they want =]): how to set up Linux to cross-compile to a Windows target. In less geek-speak that means to make Linux make programs that run on Windows.

This is really really easy. However, it took me about 3 google searches before I found out how to do it.

If you have Debian, all you have to do is install all the mingw packages. Either look them up in Synaptic or run ap-get install mingw32. That should catch all the dependencies.

Once this is done, you are good to go! Congratulations!

Alright, so now you need to know how to actually use the tools. Well, if you're a wimp and use an IDE, you can just set your IDE up to use the compiler (which I'll mention in a minute). If you're a hard-core programmer who uses just ed and gcc, it's a little harder. (But not much.)

Anyhow, the actual compiler executable is in /usr/bin. It's called something like i586-mingw32msvc-c++. Now, you could just use it like this, and type in that really long name whenever you want to compile. (IDE users: this is the executable to set your compiler up with.)

Or, you could cheat, and set up a symbolic link (ln -s, to get you started =]) with a name like mingw-c++, which is what I did.

You're good! Mingw syntax is pretty much the same as gcc, so you don't have to learn a bunch of new tricks.

Oh, you might want to install Wine to test your windows executables, now that you can make them.

No comments: