Similarities and differences between mingw and cygwin

Source: Internet
Author: User

First, both mingw and cygwin can be used for cross-platform development.
Mingw is short for minimalistic GNU for windows, that is, GCC for Windows.
Cygwin fully simulates Linux interfaces and provides them to programs running on them. It also provides a large number of ready-made software, more like a platform.
Mingw also has a sub-project called msys (minimal system). It mainly provides a shell to simulate Linux and some basic Linux tools. It is not enough to compile a large program by using gcc alone. You also need tools such as Autoconf to configure the project, therefore, in windows, compilation of FFMPEG and other large Linux projects is generally completed through msys. Of course, msys is only an auxiliary environment, and the fundamental work is done by mingw.

Differences between programs compiled by mingw and cygwin.
First, both mingw and cygwin cannot directly run programs in Linux on Windows, and must be re-compiled through source code.
The basic design concepts of modern operating systems, including Windows and Linux, are similar to the virtual memory in process thread address space. The reason why these two programs are not compatible, mainly because of their differences in the specific implementation of these functions, the first is the executable file format, the window uses the PE format, and requires. EXE is the suffix. ELF is used in Linux. Second, the operating system APIs are different. For example, in windows, CreateProcess () is used to create a process, while in Linux, fork () is used ().
Therefore, to transplant a program, it is necessary to change these areas. mingw has a dedicated w32api header file to replace the Linux-based system call in the Code with the corresponding windows method. Cygwin implements the conversion of this API through the cygwin1.dll file, and simulates a Linux system call interface to the program. The program still calls the system API in Linux mode, but this API is on cygwin1.dll, and cygwin1.dll calls the corresponding implementation of windows to return the result to the program.
You can verify this by checking the import table of the compiled program.
The programs generated by both are EXE files that can be run on Windows. Obviously, they are all in PE format. You can use a PE format check tool to check whether the programs generated by cygwin still have fork () such a Linux system is called, but the target library is cygwin1. All programs generated by mingw use the standard Windows system API exported from Kernel32.
In this case, the performance of the program compiled with mingw will be higher, and the cygwin1.dll file close to two megabytes does not need to be carried.
However, cygwin has a complete simulation of Linux. Even a cygwin X Project can be used to directly run X with cygwin.
In addition, cygwin can set-MnO-cygwin flag to use mingw for compilation.
The tools on msys, which are more comparable to cygwin, are provided through the simulation of cygwin.
In short, these two projects are closely related. For an inappropriate example, if mingw is MFC, cygwin is. net.

 

==================================

1. Modify the compiler and let the compiler in the window translate fork calls into equivalent forms-this is the mingw practice.
2. modify the library so that window provides a library similar to that provided by Unix. Their interfaces to the program are the same as those of UNIX, of course, it is implemented by Win32 API-this is cygwin's practice.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.