Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The difference between mingw and cygwin

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report