Original source: http://www.cnblogs.com/fancybit/archive/2012/07/08/2581590.html
GNS Toolchain: GCC is a compiler under Linux
POSIX API: Portable Operating System interface
First, both MinGW and Cygwin can be used for cross-platform development.
MinGW is the minimalistic GNU for Windows abbreviation, which is the win version of GCC.
Cygwin is a comprehensive simulation of the Linux interface, provided to run on the program used in it, and provides a large number of ready-made software, more like a platform.
The relative MinGW also has a sub-project called Msys (Minimal SYStem), which mainly provides a simulation of the Linux shell and some basic Linux tools. Because compiling a large program, relying on a GCC is not enough, but also need to have autoconf and other tools to configure the project, so generally under the Windows compiled FFmpeg Linux and other large projects are done through Msys, of course, Msys is only a secondary environment, The basic work is still mingw to do.
The difference between the programs compiled with MinGW and Cygwin.
First of all, MinGW and Cygwin can not let Linux under the program run directly on Windows, must be recompiled through the source code.
Modern operating systems including Windows and Linux basic design concepts like process thread address space virtual memory These are all the same, the reason is that the program is not compatible, mainly their implementation of these features of the differences, the first is the format of the executable file, window using the format of PE, also requirements with. EXE is the suffix name. Linux uses the elf. Second, the operating system's API is also different, such as Windows with CreateProcess () to create a process, while Linux uses fork ().
So to transplant the program must be in these places to change, MinGW has a dedicated W32API header file, to the code in the Linux system calls to replace the corresponding Windows mode. And Cygwin by cygwin1.dll this file to achieve this kind of API conversion, and simulation of a Linux system call interface to the program, the program still calls the system API in Linux, but this API on cygwin1.dll, cygwin1.dll again call windows The corresponding implementation, to return the results to the program.
You can verify this by looking at the import table of their compiled programs.
Both of the generated programs are EXE files that can be run on Windows, obviously PE format, with a PE format viewing tool can be found, Cygwin generated programs still have fork () such a Linux system call, but the target library is cygwin1. The MinGW generated programs use the standard Windows system APIs exported from KERNEL32.
In this way, it appears that the program compiled with MinGW will have a higher performance and no need to take that close to the two trillion cygwin1.dll file.
But Cygwin to Linux simulation is more complete, even have a Cygwin x project, you can run x directly with Cygwin.
In addition, Cygwin can set-mno-cygwin flag to compile with MinGW.
The tools on the Msys, which are more comparable to Cygwin, are also provided by Cygwin such simulations.
In short, these two projects are inextricably linked, an inappropriate analogy, if MinGW is Mfc,cygwin is. Net.
=====================
1. Modify the compiler so that the compiler under window translates calls such as fork into equivalent form-this is MinGW's approach.
2. Modify the Library so that window provides a Unix-like library that interfaces to programs like UNIX, and these libraries, of course, are implemented by the Win32 API-this is Cygwin's approach.
The difference between MinGW and Cygwin