Is it possible to develop Win32 C++ applications under a Linux distribution? If it is then how do I do this?

I know about Virtual machines, but I'm looking for something that wouldn't require to emulate a whole OS.

Recommended Answers

All 5 Replies

Windows does support the POSIX interfaces, but writing code that works equally on Windows as on Unix is not simple, especially if you want to write GUI applications. In such a case, you would be best served by using a platform neutral SDK such as Qt. That provides a means to write C++ code that will run on any number of different operating systems without recoding - just recompilation.

I have heard that it is possible to set up a cross-compiler environment which will allow you to build executables for other platforms from within Linux, but I've never looked into it. The few cross-platform apps I've worked on have been done as per Rubbermans post.
e.g.
Using cross-platform libraries like QT or wxWidgets, separating any platform specific (or even compiler specific) code using #ifdef statements and using the preprocessor to perform conditional compilation. Then when it came to building the apps on different target platforms, it was a case of compiling the code in the targets native environment using a supported compiler.

I think google might be your friend here.
Here are a few links I found on the topic...
About cross-compilation:
http://en.wikipedia.org/wiki/Cross_compiler#GCC_and_cross_compilation
Cross-compiling wxWidgets for Windows on Linux:
http://wiki.wxwidgets.org/Cross-Compiling_Under_Linux#Cross-compiling_under_Linux_for_MS_Windows
MinGW as a cross compiler on Linux:
http://www.mingw.org/wiki/LinuxCrossMinGW

From an initial glance it looks like it'll be a bit of a pain to set up and get working. Good luck!

Thank you, mates! I think Qt will work for me.

Member Avatar for jmichae3

I have heard that it is possible to set up a cross-compiler environment which will allow you to build executables for other platforms from within Linux, but I've never looked into it. The few cross-platform apps I've worked on have been done as per Rubbermans post.
e.g.
Using cross-platform libraries like QT or wxWidgets, separating any platform specific (or even compiler specific) code using #ifdef statements and using the preprocessor to perform conditional compilation. Then when it came to building the apps on different target platforms, it was a case of compiling the code in the targets native environment using a supported compiler.

I think google might be your friend here.
Here are a few links I found on the topic...
About cross-compilation:
http://en.wikipedia.org/wiki/Cross_compiler#GCC_and_cross_compilation
Cross-compiling wxWidgets for Windows on Linux:
http://wiki.wxwidgets.org/Cross-Compiling_Under_Linux#Cross-compiling_under_Linux_for_MS_Windows
MinGW as a cross compiler on Linux:
http://www.mingw.org/wiki/LinuxCrossMinGW

From an initial glance it looks like it'll be a bit of a pain to set up and get working. Good luck!

mingw I believe has compilers for
mac to mac (both 32 and 64-bit host-to-target),
windows-32 host to freebad target,
windows-32 host to ubuntu target,
windows-32 host to windows-32 target
windows-32 host to windows-64 target
windows-64 host to windows-64 target

and these are the ones that I know about. there are a number of flavors of windows compilers, including personal builds.
the windows hosted programs require the cmd shell, which linux does not have.

cygwin build environment can be used on windows for porting *nix software to windows, but it runs on windows, and has its own BASH. it has a fair number of linux utilities, it makes a massive build environment and you can spend an entire day downloading it all if you want.

I don't know of any cross-compilers that host on linux and compile for windows. I don't think that has been proposed on mingw-w64 users mailing list yet, but it would be interesting to see of someone does it. I can suggest it.

mingw and mingw-w64 both require microsoft's msvcrt.dll to work.
they do NOT generate standalone code.
this DLL is providedwith the OS, however, the DLL's list of functions change with time. for instance, using _ftelli64() or _fseeki64() will cause an error on windows 9x/me, since a 64-bit filesystem was not invented at that time. that was invented later when NTFS came along.

Fedora has a win32 cross compiler that uses mingw and wine.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.