Helpful Information
 
 
Category: C Programming
Question about Compilers

I have a different kind of question. I was wondering if there is a compiler that will compile C/C++ programs that run on Windows and Unix/Linux?

Thanks,
Jonathan Donaghe

I have never used the following product so I can't tell you anything about it:

http://www.mainsoft.com/products/mainwin.html

The GNU compiler (http://www.gnu.org/software/gcc/gcc.html) is available for both platforms. If you're asking whether you can compile a program on Windows and have it run on *nix, then no. The executable formats aren't compatible.*

* This isn't entirely true - you could get a cross compiler, but you'd still have to compile two different versions - one for Windows, one for *nix. You're better off just compiling on the intended platform.

EDIT: See the above post.

You can write a C/C++ program for both system types by the use of include directives to define which sections should be included in on windoze systems and *nix systems.
The link that jonsagara listed for the gnu compiler is what you are looking for, you can get it integrated also if you get the cygwin environment (plus some excellent unix commands).
Also, as jon said, you can't compile it on one system and that executable run on the other, they are incompatable in that aspect. You have to compile the source code on the os type you wish to run it on. The other problem, especially if you are writting window style applications, they will not port over at all, unless you use something like the wxWindows library to build the program, which will port to either system, but you still have to compile it on the system you want to run it on.

Yet another clewless poster who can't read dates.










privacy (GDPR)