Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there anyway to create (C++ or C#) windows console applications inside Ubuntu's IDE (e.g Anjuta) and compile it for Windows?

share|improve this question
mingw is the obvious choice for cross-compiling, but i have no idea how to integrate it with Anjunta. I did see a tutorial on integrating mingw and kdevelop here: maybe one of the folks recommending mingw knows of an integration with Anjunta tutorial? – RobotHumans Nov 22 '10 at 20:42
up vote 19 down vote accepted

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.

share|improve this answer

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.

share|improve this answer
good enough for me +1 – RobotHumans Nov 22 '10 at 20:59

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.

share|improve this answer

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.

share|improve this answer

The most common way to program windows application linux (ubuntu) is using the mingw tools:

There are ubuntu packages for mingw ready to install.

share|improve this answer

From this page:

> sudo apt-get install wine mingw32 mingw32-binutils mingw32-runtime

This is all what is needed for basic cross-compilation. Let's make a try:

#include <windows.h>

int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
    "Cette fenêtre prouve que le cross-compilateur est fonctionnel !",
    "Hello World", MB_OK);
  return 0;

Compile this using:

> i586-mingw32msvc-g++ -o essai.exe essai.cpp

To execute, you need the mingw library: mingwm10.dll:

> gunzip -c /usr/share/doc/mingw32-runtime/mingwm10.dll.gz > mingwm10.dll

Then you can launch it:

> wine essai.exe

The text of the dialog box is in French language with an accent, to do it with gvim, convert the source to windows code page 1252: <ESC>:e ++enc=cp1252

Another solution, more powerful is to using UTF-8 but requires to change the way strings are handled.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.