As of 2015, the best general purpose development environment for C/C++ programs on Windows seems to be MSYS2.
The MSYS2 environment actually supports multiple different sub-environments. The main difference between these environments is that they each provide a different compiler. In each environment, the compiler is invoked by running "gcc".
The executables compiled by gcc in the MSYS2 Shell depend on msys-2.0.dll. That DLL is a fork of Cygwin, so it provides good POSIX
support, including the fork
function. It doesn't define the _WIN32
preprocessor macro by default, but it will if you provide the -mwin32
options.
The MSYS2 Shell is useful for compiling GNU utilities, applications that use advanced features of POSIX, or just generally any application that was not designed with Windows in mind. For example, if you wanted to compile the latest version of GNU Grep, you should use the MSYS2 Shell.
Most of the utilities provided by MSYS2 were probably compiled using the MSYS2 environment; if you run Dependency Walker and look at those utilities, you can see that they depend on msys-2.0.dll. According to Elieux, the -mwin32
option is not really used in the MSYS2 project, so most of these utilities are probably "unaware" that they are running on Windows.
As of 2015-03-22, compile-time errors prevent you from using Microsoft's setupapi.h from this environment. This makes me think that most people don't compile Windows-aware applications in this environment, and instead use one of the other environments.
The features of POSIX available to you in this environment are more limited. For example, fork is not available, and fstat
always returns a 0 in st_ino
field. I think that the features of POSIX that are available mostly come from MSVCRT.DLL, and these features are documented in the Run-time Library Reference for Visual Studio .NET 2003 on MSDN. Click on "Alphabetical Function Reference" in that document to find specific functions. It is important to note that newer versions of the Microsoft development tools (i.e. Visual Studio) use newer C run-time DLLs with numbers in the name, like MSVCR110.DLL. These newers DLLs might provide features that are unavailable in MinGW.
The MinGW-w64 Win32 Shell is very similar to the MSYS2 Shell. The main difference is that "/mingw32/bin" is prepended to the path, and a few other environment variables are adjusted as well. You can see all the differences in the two shells by looking at the use of the MSYSTEM
variable in /etc/profile. A lot of utilities on the PATH, like "ls" and "make", are MSYS programs (they depends on msys-2.0.dll), but that is fine.
The MinGW-w64 Win32 Shell is my preferred environment for compiling the cross-platform, Windows-aware programs that I want to write. I like that the compiled executables can stand alone, without needing msys-2.0.dll. I like that you can use Microsoft APIs like WinUSB, and also have all the language features from the latest version of GCC.
To use this environment you should first install the MinGW compiler using pacman:
pacman -S mingw-w64-i686-toolchain
If you just want to get the mingw-w64 compiler without all this MSYS stuff, you can download those compilers from the mingw-w64 website.
I haven't tried it, but I assume the MinGW-w64 Win64 Shell is just like the Win32 version except the executables you create a 64-bit, so they will only work on 64-bit versions of Windows. You would install the mingw-w64-x86_64-toolchain package group to use this environment.
dg_end();?>