How to program for Windows in Ubuntu?

Solution 1:

You want to do cross-compiling, which is a way to compile code for platforms other than the one your on, especially when the processor is completely different. Basically you need to install all the headers for your target (i.e. windows) and then tell the compiler it's cross-compiling so it won't do some of the system checks and instead will point to non-standard directories.

Depending on the language you might find it useful to do a search or question specifically, or if you're doing basic c you can use MinGW tools and the same sort of linux based compile tools that use gcc:

sudo apt-get install gcc-mingw32

There is a good guide for qt/win32 cross compiling using MinGW tools.

Solution 2:

You should have a look at MingW. It provides a gcc-compatible compiler for windows.

There is a cross-platform version that you can use from Linux, to generate Windows binaries. You can install it with synaptic, or by running:

sudo apt-get install gcc-mingw32

Based on that, and with using the usual 'make' command, you can create programs for windows.

Then any IDE that allows you to use make and gcc can use this compiler. For instance, here is how to do that from the Code::Blocks IDE.

Solution 3:

The other answers are correct for C/C++ code; you'll need to get a cross-compiler.

For C# code, you can just use Monodevelop Install Monodevelop, as Mono's compiler produces the same type of bytecode and executable format as the .NET compiler (and visa versa). Apps you build with Mono will run unmodified on Windows machines as long as you stay within the standard .NET Base Class Libraries or bundle any extra library you use with your app.

Solution 4:

Might want to give Qt with Qt Creator a try. Great framework for GUI and Console application you can the compile for Windows, Linux and OS X.

http://qt.nokia.com/