I don't quite understand the difference between the following C/C++ compilers: GCC, MinGW, Cygwin and MSVC. Are the MinGW and Cygwin implementations of GCC or something entirely different? If I intend to compile for Windows, do I ever need anything other than the MSVC (Visual Studio) compiler?
1 Answer
GCC for Windows is mostly useful for makefiles and code written with gcc-specific non-portable syntax.
cygwin is not a compiler, it's a set of libraries that create a Linux-like environment inside Windows, and common linux tools compiled with those libraries.. It is useful for code written with Unixisms (expect files to behave a certain way, or assume the directory separator is /, or assume Linux paths).
If you have pure Windows code, you'll be happiest with Visual C++ (MSVC). Or, if that doesn't optimize well enough, the Intel C++ compiler.
Visual C++ also works well for portable ISO-conformant code... but Microsoft is a little behind the curve on implmenting C++11 and C++14 features. So that's another reason you might want to use gcc (or clang).
7 Comments
-mwindows and -mno-windows don't specify Cygwin/without-Cygwin. Those options specify that the produced program is a Windows GUI or Windows Console program respectively. If you're targeting the Cygwin platform, then you need a gcc compiler that targets Cygwin. If you're targeting a native Win32 platform program then you need a gcc compiler that targets mingw32 (ie., Win32). Different runtimes are used. Cygwin GCC compilers used to be able to target native Win32, but a long time ago that support was dropped as being a waste of effort.-mno-cygwin, and it's since been discontinued. Are you sure the capability is completely gone? I would imagine that it remains possible using a cross-compiler (using the same cross-compile logic used to build mingw-runtime apps on Linux).