Find the answer to your Linux question:
Results 1 to 4 of 4
I'm developing an application that needs to run on both linux and windows. Does gcc have the capability to produce windows executables? If it does not then is there any ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2013
    Posts
    53

    gcc question


    I'm developing an application that needs to run on both linux and windows. Does gcc have the capability to produce windows executables? If it does not then is there any other linux compiler that does?

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,755
    You can build Linux applications (for the most part) on Windows using the MingW (GCC-based) compiler. I don't know of a cross-compilation GCC tool chain to build Windows applications directly in a Linux environment - most of the needed DLL's would not be available as they are proprietary to MS.

    As for building a cross-platform application such as you say you need to do, you must be careful to avoid using libraries (API's) that are restricted to one or the other platform. Fortunately, most Linux code will build easily on Windows systems and run fine (I do a lot of that). There are a number of caveats that are too complex to get into here, but most have to do with export/import directives that Windows applications need if you are going to build shared libraries that can be implemented in both Windows and Linux systems. Linux doesn't need those directives, so usually there are platform macros that will compile out such directives for Linux, and leave them in for Windows.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Apr 2013
    Posts
    53
    Thank you for the answer. Sounds a lot more complicated than I want it to be. Right now I have to keep 2 source sets for each cross platform program that I develop, i.e., one for visual studio and one for glade/gcc. I was hoping for a simplification.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,755
    Quote Originally Posted by BowCatShot View Post
    Thank you for the answer. Sounds a lot more complicated than I want it to be. Right now I have to keep 2 source sets for each cross platform program that I develop, i.e., one for visual studio and one for glade/gcc. I was hoping for a simplification.
    Well, I've been doing cross-platform development (Windows, Unix, QNX, and Linux) for many, many years, and never had to keep two source sets. The key is in the platform include files. The original setup is a bit onerous, but once you get it sorted out, you pretty much don't need to do much other than recompile on the platform of choice. I used VS for Windows, and GCC and other C++ compilers for other systems. We had 10M lines of code that compiled and ran identically on Windows, Unix (32 and 64 bit versions of Tru64, Ultrix, Solaris/SunOS, System-V, HPUX (9 and up), and Linux. There were zero code differences, other than what we did in the platform include files to deal with subtle peculiarities. That code base included shared libraries (plug-ins), database interfaces, SOAP/UML messaging, and more. FWIW, that code runs most of the semiconductor, flat-panel display, and disc drive plants in the world today...

    So, yes it is a bit complicated. No, it isn't impossible. And finally, it will give you a great understanding of the issues involved with cross-platform development.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •