MinGw and cygwin differences and connections

Original by zoe.zhang

..........................................................

1. Different windows and Linux operating systems

    windows and Linux is now, the two most popular operating system in the basic design concepts, processes, threads, addressing, memory management, and other aspects are similar, but the program is not compatible between the two, because both function in the system is different, the system provided API is different.
  The most obvious points from it:

  • Format executable file, Windows uses a PE format required to .exe suffix name, and Linux using elf format;
  • The operating system provides a system API is different, such as Windows use CreateProcess () to create a process , but Linux uses fork () .
    So if you want to use in the Windows environment Linux build tool is gcc / g ++, we need an intermediate conversion tool or platform , which is MinGW and cygwin presence reasons.

2. What is MinGW

  • MinGw full name Minimalistic GNU for Windows, to some extent, can be seen as GCC win the next version. Mingw there is a sub-project Msys can provide some of the analog Linux shell and basic Linux tools, Msys is a secondary environment.
  • MinGw a dedicated Win32 API header files, the way to put the code in Linux system calls replaced by a call under the corresponding mode Windows, Linux calls to some extent can be called to translate for Windows calls.

3. What is cygwin

  • Cygwin is a unix simulation environment running on the Windows platform, is cygnus solutions developed by free software. Cygwin is more like a platform that simulates the Linux interface that provides programs to run on top of it to use, provides a lot of GNU software under Linux environment.
  • Cygwin is achieved by Cygwin1.dll file conversion operating system API to simulate the Linux call interface to the program, the program to invoke the Linux system API, but the API library is Cygwin1.dll goal, Cygwin1.dll then call on Windows implemented in the way, and then return the results to the program .

4. The difference between the two

  • MinGW generated program, by its very nature calls is Kernel.32 export standard Windows system API , the Mingw in the windows of some high-performance compiler, compilation speed is also faster.
  • Cygwin is more like a platform, it is relatively complete simulation of the LInux , provides a nearly 2M of Cygwin1.dll file as the target library to simulate the interface of Linux systems, but relatively speaking compiled speed will be slower. If you want to develop programs to run on LInux on Windows, you should use Cygwin.
  • In general:

    1. cygwin large and small mingw
    2. After cygwin compiled exe as cygwin1.dll need support, and mingw does not need to be run directly, because the intermediate layer so slow cygwin, mingw fast.
    3. Cygwin content included in a more comprehensive and able to compile the linux source file more, mingw of min is less minimalist it can be compiled by. However, not all, that you can not expect any source code written for linux and run through cygwin or mingw compiler.

5. MinGW、MinGw-w64、TDM-GCC

  • MinGW is the first out, but there were only 32-bit systems, it supports 32-bit systems;
  • Mingw-w64 supports both 64, also supports 32-bit, and also supports cross-compiling 32-bit and 64-bit; gcc official support Mingw-w64, it is also suggested that Mingw-w64.
  • The GCC-the TDM : using a 32 bit Mingw, 64 is position with MinGW64.
  • There is also a IDE, CodeBlock, relatively simple to use, with a strong cross-platform, more suitable for novices accustomed to using the command line.

6. Summary

   In fact, cygwin / gcc and gcc compiler environment Mingw are designed to be used in windows, can easily be programmed in some classes Linux environment. But no matter what kind of two platforms, Linux programs can not run directly under Windows, you need to recompile the program, and recommended important source or should be compiled in real Linux environment.

   Based on execution speed as well as the size of the reasons, I prefer to use MinGW64 under Windows.

Is attached; Mingw-w64 build environment

  • Download the installation package, and install, pay attention to some setting parameters of the installation.
  • Configure the environment: Environment variables enter the address installed .. \ Mingw64 \ bin.
  • Verify the configuration is successful: Open cmd command line, type gcc -v.
Published 276 original articles · won praise 134 · Views 1.05 million +

Guess you like

Origin blog.csdn.net/iamonlyme/article/details/103099174