Get the App
SLTechnology News&Howtos  ›  Servers  › 

The difference between mingw and cygwin

Shulou Source: shulou.com Published: 2022-06-02 07:13:04 10月18日 Update

MinGW and cygwin

= =

First, both MingW and cygwin can be used for cross-platform development.

MinGW is the abbreviation of Minimalistic GNU for Windows, that is, the Win version of the simplified GCC.

MinGW collects a series of free header files and library files used by Windows; at the same time, it integrates the tool set of GNU (http://www.gnu.org/), especially GNU program development tools, such as classic gcc, gaming tools, make and so on.

Microsoft has a set of unix subsystem development environment, but it is only a subset of posix, many functions of linux can not be used, of course, fork is fine.

Cygwin fully simulates the interface of Linux, provides programs running on it, and provides a large number of off-the-shelf software, more like a platform.

Relative MingW also has a subproject called MSYS (Minimal system), which mainly provides a Shell that simulates Linux and some basic Linux tools. Because compiling a large program, relying on a GCC is not enough, but also need tools such as Autoconf to configure the project, so generally compile large projects under Linux under Windows are completed through MSYS, of course, MSYS is only an auxiliary environment, the basic work is still done by MingW.

The difference between programs compiled with MingW and cygwin

= =

First of all, neither MingW nor cygwin can allow programs under Linux to run directly on Windows and must be recompiled from the source code.

The basic design concepts of modern operating systems, including Windows and Linux, such as process thread address space, virtual memory, are more or less the same. the main reason why the programs on the two are not compatible is mainly due to their differences in the implementation of these functions.

The first is the format of the executable file. Window uses the format of PE and requires the suffix .exe. Linux uses ELF.

Second, the API of the operating system is also different, such as Windows uses CreateProcess () to create processes, while Linux uses fork ().

So if you want to migrate the program, you have to change it in these places.

MinGW's plan:

To directly replace and modify the system call API under Linux in the code to the API under the corresponding Windows. So the generated execution file can no longer see linux's system call api.

Cygwin scenario:

Cygwin uses cygwin1.dll as a dynamic library to transform the API of the two platforms. The programs generated by Cygwin still have Linux system calls API such as fork (), but the conversion to Windows functions is implemented in cygwin1.dll.

Programs compiled with Mingw will perform better, and you don't have to carry the nearly two-megabyte cygwin1.dll file.

[to sum up]

1. Modify the compiler to have the compiler under window translate calls such as fork into equivalent forms-this is what mingw does.

two。 Modify the library so that window provides a library similar to that provided by unix, and they have the same interface to the program as unix, and these libraries are, of course, implemented by win32's API-- this is what cygwin does.

Tags: Programs compilers systems tools files development operating systems practices functions just that is platforms interfaces schemes formats environments compilers processes projects generation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL Linux macOS Huawei Xiaomi