cross-platform C++ compilation

Sorry if this belongs in the newbies forum and the moderator should feel free to move it there if needed. No hard feelings either way.

I wrote a simple practice application in Debian 7.7 and compiled it using g++ 4.7.2. I made sure the executable had an .exe extension. The application compiled with no errors and executed in Debian with no semantic errors, but would not execute at all in Windows 7. So I guess I've discovered that I need to compile it in a special way in order to have it execute in both Linux and Windows. What is that special way?
Linux and windows executable are not compatible at all. You need to produce 2 executable files: one for Linux and second for Windows.
Thank you for the quick reply. Is there a way to compile a Windows executable from within Linux?
Yes. There is. Google for something like cross compilation to windows or Target Windows gcc. For example top result in search http://www.blogcompiler.com/2010/07/11/compile-for-windows-on-linux/

If you are using clang, everything is easier: http://clang.llvm.org/docs/CrossCompilation.html
Topic archived. No new replies allowed.