windows Cygwin 和 MinGW 有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/771756/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 06:16:16  来源:igfitidea点击:

What is the difference between Cygwin and MinGW?

windowscygwinmingw

提问by ?ukasz Lew

I want to make my C++ project cross platform, and I'm considering using Cygwin/MinGW. But what is the difference between them ?

我想让我的 C++ 项目跨平台,我正在考虑使用 Cygwin/MinGW。但是它们之间有什么区别呢?

Another question is whether I will be able to run the binary on a system without Cygwin/MinGW ?

另一个问题是我是否能够在没有 Cygwin/MinGW 的系统上运行二进制文件?

采纳答案by thomasrutter

As a simplification, it's like this:

作为简化,它是这样的:

  • Compile something in Cygwin and you are compiling it for Cygwin.

  • Compile something in MinGW and you are compiling it for Windows.

  • 在 Cygwin 中编译一些东西,你正在为 Cygwin编译它。

  • 在 MinGW 中编译一些东西,你正在为 Windows编译它。

About Cygwin

关于 Cygwin

The purpose of Cygwin is to make porting Unix-based applications to Windows much easier, by emulating many of the small details that Unix-based operating systems provide, and are documented by the POSIXstandards. Your application can use Unix feature such as pipes, Unix-style file and directory access, and so forth, and it can be compiled with Cygwin which will act as a compatibility layeraround your application, so that many of those Unix-specific paradigms can continue to be used.

Cygwin 的目的是通过模拟基于 Unix 的操作系统提供并由POSIX标准记录的许多小细节,使基于 Unix 的应用程序移植到 Windows 变得更加容易。您的应用程序可以使用 Unix 特性,例如管道、Unix 样式的文件和目录访问等,并且可以使用 Cygwin 进行编译,Cygwin 将充当您应用程序的兼容层,因此许多特定于 Unix 的范例可以继续使用。

When you distribute your software, the recipient will need to run it along with the Cygwin run-time environment (provided by the file cygwin1.dll). You may distribute this with your software, but your software will have to comply with its open source license. It may even be the case that even just linking your software with it, but distributing the dll separately, may still require you to honor the open source license.

当您分发软件时,接收者需要将它与 Cygwin 运行时环境(由文件提供cygwin1.dll)一起运行。您可以将其与您的软件一起分发,但您的软件必须遵守其开源许可证。甚至可能只是将您的软件与其链接,但单独分发 dll,可能仍然需要您遵守开源许可证。

About MinGW

关于明威

MinGW aims to simply be a Windows port of the GNU compiler tools, such as GCC, Make, Bash, and so on. It does not attempt to emulate or provide comprehensive compatibility with Unix, but instead it provides the minimum necessary environment to use GCC (the GNU compiler) and a small number of other tools on Windows. It does not have a Unix emulation layer like Cygwin, but as a result your application needs to specifically be programmed to be able to run in Windows, which may mean significant alteration if it was created to rely on being run in a standard Unix environment and uses Unix-specific features such as those mentioned earlier. By default, code compiled in MinGW's GCC will compile to a native Windows X86 target, including .exe and .dll files, though you could also cross-compile with the right settings, since you are basically using the GNU compiler tools suite.

MinGW 旨在简单地成为 GNU 编译器工具(例如 GCC、Make、Bash 等)的 Windows 端口。它不试图模拟或提供与 Unix 的全面兼容性,而是提供在 Windows 上使用 GCC(GNU 编译器)和少量其他工具所需的最低限度的环境. 它没有像 Cygwin 那样的 Unix 仿真层,但因此,您的应用程序需要专门编程才能在 Windows 中运行,如果创建它依赖于在标准 Unix 环境中运行,这可能意味着重大更改使用 Unix 特定的功能,例如前面提到的那些。默认情况下,在 MinGW 的 GCC 中编译的代码将编译为本地 Windows X86 目标,包括 .exe 和 .dll 文件,但您也可以使用正确的设置进行交叉编译,因为您基本上使用的是 GNU 编译器工具套件。

MinGW is essentially an alternative to the Microsoft Visual C++compiler and its associated linking/make tools. It may be possible in some cases to use MinGW to compile something that was intended for compiling with Microsoft Visual C++, with the right libraries and in some cases with other modifications.

MinGW 本质上是Microsoft Visual C++编译器及其相关链接/制作工具的替代品。在某些情况下,可以使用 MinGW 来编译一些旨在使用 Microsoft Visual C++ 编译的内容,使用正确的库,在某些情况下进行其他修改。

MinGW includes some basic standard libraries for interacting with the Windows operating system, but as with the normal standard libraries included in the GNU compiler collection these don't impose licensing restrictions on software you have created.

MinGW 包含一些用于与 Windows 操作系统交互的基本标准库,但与 GNU 编译器集合中包含的普通标准库一样,这些库不会对您创建的软件施加许可限制。

For non-trivial software applications, making them cross-platform can be a considerable challenge unless you use a comprehensive cross-platform framework. At the time I wrote this the Qt frameworkwas one of the most popular for this purpose, allowing the building of graphical applications that work across operating systems including Windows, but there are other options too. If you use such a framework from the start, you can not only reduce your headaches when it comes time to port to another platform but you can use the same graphical widgets - windows, menus and controls - across all platforms if you're writing a GUI app, and have them appear native to the user.

对于非平凡的软件应用程序,除非您使用全面的跨平台框架,否则使它们跨平台可能是一个相当大的挑战。在我写这篇文章的时候,Qt 框架是最流行的框架之一,它允许构建跨操作系统(包括 Windows)工作的图形应用程序,但也有其他选项。如果您从一开始就使用这样的框架,那么您不仅可以减少移植到另一个平台时的麻烦,而且您可以在所有平台上使用相同的图形小部件 - 窗口、菜单和控件 - 如果您正在编写一个GUI 应用程序,并让它们对用户来说是原生的。

回答by thomasrutter

Cygwin is an attempt to create a complete UNIX/POSIX environment on Windows. To do this it uses various DLLs. While these DLLs are covered by GPLv3+, their license contains an exceptionthat does not force a derived work to be covered by the GPLv3+. MinGW is a C/C++ compiler suite which allows you to create Windows executables without dependency on such DLLs - you only need the normal MSVC runtimes, which are part of any normal Microsoft Windows installation.

Cygwin 试图在 Windows 上创建一个完整的 UNIX/POSIX 环境。为此,它使用了各种 DLL。虽然 GPLv3+ 涵盖这些 DLL,但它们的许可证包含一个例外该例外不强制 GPLv3+ 涵盖派生作品。MinGW 是一个 C/C++ 编译器套件,它允许您创建 Windows 可执行文件而不依赖于此类 DLL - 您只需要普通的 MSVC 运行时,这是任何普通 Microsoft Windows 安装的一部分。

You can also get a small UNIX/POSIX like environment, compiled with MinGW called MSYS. It doesn't have anywhere near all the features of Cygwin, but is ideal for programmers wanting to use MinGW.

您还可以获得一个类似 UNIX/POSIX 的小型环境,使用名为MSYS 的MinGW 编译。它没有 Cygwin 的所有功能,但对于想要使用 MinGW 的程序员来说是理想的选择。

回答by TrayMan

To add to the other answers, Cygwin comes with the MinGW libraries and headers and you can compile without linking to the cygwin1.dll by using -mno-cygwin flag with gcc. I greatly prefer this to using plain MinGW and MSYS.

要添加到其他答案中,Cygwin 附带了 MinGW 库和头文件,您可以在不链接到 cygwin1.dll 的情况下通过使用带有 gcc 的 -mno-cygwin 标志进行编译。我非常喜欢使用普通的 MinGW 和 MSYS。

回答by dirkgently

Wikipedia does a comparison here.

维基百科在这里做了一个比较。

From Cygwin's website:

从 Cygwin 的网站

  • Cygwin is a Linux-like environment for Windows. It consists of two parts: A DLL (cygwin1.dll) which acts as a Linux API emulation layer providing substantial Linux API functionality.
  • A collection of tools which provide Linux look and feel.
  • Cygwin 是一个类似 Linux 的 Windows 环境。它由两部分组成: 一个 DLL (cygwin1.dll),它充当 Linux API 仿真层,提供大量 Linux API 功能。
  • 提供 Linux 外观和感觉的工具集合。

From Mingw's website:

来自 Mingw 的网站

MinGW ("Minimalistic GNU for Windows") is a collection of freely available and freely distributable Windows specific header files and import libraries combined with GNU toolsets that allow one to produce native Windows programs that do not rely on any 3rd-party C runtime DLLs

MinGW(“Minimalistic GNU for Windows”)是一组免费可用且可自由分发的 Windows 特定头文件和导入库与 GNU 工具集相结合,允许生成不依赖任何 3rd-party C 运行时 DLL 的本机 Windows 程序

回答by Michael Burr

Cygwin uses a DLL, cygwin.dll, (or maybe a set of DLLs) to provide a POSIX-like runtime on Windows.

Cygwin 使用 DLL、cygwin.dll(或可能是一组 DLL)在 Windows 上提供类似 POSIX 的运行时。

MinGW compiles to a native Win32 application.

MinGW 编译为本机 Win32 应用程序。

If you build something with Cygwin, any system you install it to will also need the Cygwin DLL(s). A MinGW application does not need any special runtime.

如果您使用 Cygwin 构建某些东西,那么您将其安装到的任何系统也将需要 Cygwin DLL。MinGW 应用程序不需要任何特殊的运行时。

回答by Amir Saniyan

Read these answered questions to understand the difference between Cygwin and MinGW.

阅读这些已回答的问题以了解 Cygwin 和 MinGW 之间的区别。



Question #1: I want to create an application that I write source code once, compile it once and run it in any platforms (e.g. Windows, Linux and Mac OS X…).

问题#1:我想创建一个应用程序,我编写一次源代码,编译一次并在任何平台(例如 Windows、Linux 和 Mac OS X...)上运行它。

Answer #1: Write your source code in JAVA. Compile the source code once and run it anywhere.

答案 #1:用 JAVA 编写源代码。一次编译源代码并在任何地方运行它。



Question #2: I want to create an application that I write source code once but there is no problem that I compile the source code for any platforms separately (e.g. Windows, Linux and Mac OS X …).

问题#2:我想创建一个应用程序,我编写了一次源代码,但我为任何平台(例如 Windows、Linux 和 Mac OS X ……)单独编译源代码都没有问题。

Answer #2: Write your source code in C or C++. Use standard header files only. Use a suitable compiler for any platform (e.g. Visual Studio for Windows, GCC for Linux and XCode for Mac). Note that you should not use any advanced programming features to compile your source code in all platforms successfully. If you use none C or C++ standard classes or functions, your source code does not compile in other platforms.

答案 #2:用 C 或 C++ 编写源代码。仅使用标准头文件。为任何平台使用合适的编译器(例如 Windows 的 Visual Studio、Linux 的 GCC 和 Mac 的 XCode)。请注意,您不应使用任何高级编程功能在所有平台上成功编译源代码。如果您不使用 C 或 C++ 标准类或函数,则您的源代码不会在其他平台上编译。



Question #3: In answer of question #2, it is difficult using different compiler for each platform, is there any cross platform compiler?

问题#3:在问题#2的回答中,每个平台使用不同的编译器是很困难的,有没有跨平台的编译器?

Answer #3: Yes, Use GCC compiler. It is a cross platform compiler. To compile your source code in Windows use MinGWthat provides GCC compiler for Windows and compiles your source code to native Windows program. Do not use any advanced programming features (like Windows API) to compile your source code in all platforms successfully. If you use Windows API functions, your source code does not compile in other platforms.

答案 #3:是的,使用 GCC 编译器。它是一个跨平台的编译器。要在 Windows 中编译源代码,请使用为 Windows 提供 GCC 编译器的MinGW,并将源代码编译为本地 Windows 程序。不要使用任何高级编程功能(如 Windows API)在所有平台上成功编译源代码。如果您使用 Windows API 函数,则您的源代码不会在其他平台上编译。



Question #4: C or C++ standard header files do not provide any advanced programming features like multi-threading. What can I do?

问题 #4:C 或 C++ 标准头文件不提供任何高级编程功能,如多线程。我能做什么?

Answer #4: You should use POSIX (Portable Operating System Interface [for UNIX]) standard. It provides many advanced programming features and tools. Many operating systems fully or partly POSIX compatible (like Mac OS X, Solaris, BSD/OS and ...). Some operating systems while not officially certified as POSIX compatible, conform in large part (like Linux, FreeBSD, OpenSolaris and ...). Cygwinprovides a largely POSIX-compliant development and run-time environment for Microsoft Windows.

答案 #4:您应该使用 POSIX(便携式操作系统接口 [用于 UNIX])标准。它提供了许多高级编程功能和工具。许多操作系统完全或部分兼容 POSIX(如 Mac OS X、Solaris、BSD/OS 和...)。一些操作系统虽然没有正式认证为 POSIX 兼容,但在很大程度上符合(如 Linux、FreeBSD、OpenSolaris 和...)。Cygwin为 Microsoft Windows 提供了一个很大程度上符合 POSIX 的开发和运行时环境。



Thus:

因此:

To use advantage of GCC cross platform compiler in Windows, use MinGW.

要在 Windows 中利用 GCC 跨平台编译器的优势,请使用 MinGW。

To use advantage of POSIX standard advanced programming features and tools in Windows, use Cygwin.

要在 Windows 中利用 POSIX 标准高级编程功能和工具,请使用 Cygwin。

回答by Kaz

From the point of view of porting a C program, a good way to understand this is to take an example:

从移植C程序的角度来看,理解这一点的一个好方法是举个例子:

#include <sys/stat.h>
#include <stdlib.h>

int main(void)
{
   struct stat stbuf;
   stat("c:foo.txt", &stbuf);
   system("command");
   printf("Hello, World\n");
   return 0;
}

If we change statto _stat, we can compile this program with Microsoft Visual C. We can also compile this program with MinGW, and with Cygwin.

如果我们stat改为_stat,我们可以用 Microsoft Visual C 编译这个程序。我们也可以用 MinGW 和 Cygwin 编译这个程序。

Under Microsoft Visual C, the program will be linked to a MSVC redistributable run-time library: mxvcrtnn.dll, where nnis some version suffix. To ship this program we will have to include that DLL. That DLL provides _stat, systemand printf. (We also have the option of statically linking the run-time.)

在 Microsoft Visual C 下,程序将链接到 MSVC 可再发行运行时库:mxvcrtnn.dll,其中nn是某个版本后缀。要发布此程序,我们必须包含该 DLL。该 DLL 提供_stat,systemprintf. (我们还可以选择静态链接运行时。)

Under MinGW, the program will be linked to msvcrt.dll, which is an internal, undocumented, unversioned library that is part of Windows, and off-limits to application use. That library is essentially a fork of the redistributable run-time library from MS Visual C for use by Windows itself.

在 MinGW 下,该程序将链接到msvcrt.dll,这是一个内部的、未记录的、未版本控制的库,它是 Windows 的一部分,并且禁止应用程序使用。该库本质上是 MS Visual C 的可再发行运行时库的分支,供 Windows 本身使用。

Under both of these, the program will have similar behaviors:

在这两种情况下,程序将具有类似的行为:

  • the statfunction will return very limited information—no useful permissions or inode number, for instance.
  • the path c:file.txtis resolved according to the current working directory associated with drive c:.
  • systemuses cmd.exe /cfor running the external command.
  • stat函数将返回非常有限的信息——例如,没有有用的权限或 inode 编号。
  • 该路径c:file.txt根据与 drive 关联的当前工作目录进行解析c:
  • system使用cmd.exe /c用于运行外部命令。

We can also compile the program under Cygwin. Similarly to the redistributable run-time used by MS Visual C, the Cygwin program will be linked to Cygwin's run-time libraries: cygwin1.dll(Cygwin proper) and cyggcc_s-1.dll(GCC run-time support). Since Cygwin is now under the LGPL, we can package with our program, even if it isn't GPL-compatible free software, and ship the program.

我们也可以在 Cygwin 下编译程序。与 MS Visual C 使用的可再发行运行时类似,Cygwin 程序将链接到 Cygwin 的运行时库:cygwin1.dll(Cygwin 本身)和cyggcc_s-1.dll(GCC 运行时支持)。由于 Cygwin 现在在 LGPL 之下,我们可以将我们的程序打包,即使它不是与 GPL 兼容的免费软件,并发布程序。

Under Cygwin, the library functions will behave differently:

在 Cygwin 下,库函数的行为会有所不同:

  • the statfunction has rich functionality, returning meaningful values in most of the fields.
  • the path c:file.txtis not understood at all as containing a drive letter reference, since c:isn't followed by a slash. The colon is considered part of the name and somehow mangled into it. There is no concept of a relative path against a volume or drive in Cygwin, no "currently logged drive" concept, and no per-drive current working directory.
  • the systemfunction tries to use the /bin/sh -cinterpreter. Cygwin will resolve the /path according to the location of your executable, and expect a sh.exeprogram to be co-located with your executable.
  • stat函数具有丰富的功能,在大多数字段中返回有意义的值。
  • 路径c:file.txt根本不被理解为包含驱动器号引用,因为c:后面没有斜杠。冒号被认为是名称的一部分,并以某种方式混入其中。Cygwin 中没有针对卷或驱动器的相对路径的概念,没有“当前记录的驱动器”概念,也没有每个驱动器的当前工作目录。
  • system函数尝试使用/bin/sh -c解释器。Cygwin 将/根据您的可执行文件的位置解析路径,并期望sh.exe程序与您的可执行文件位于同一位置。

Both Cygwin and MinGW allow you to use Win32 functions. If you want to call MessageBoxor CreateProcess, you can do that. You can also easily build a program which doesn't require a console window, using gcc -mwindows, under MinGW and Cygwin.

Cygwin 和 MinGW 都允许您使用 Win32 函数。如果您想拨打MessageBoxCreateProcess,您可以这样做。您还可以使用gcc -mwindows, 在 MinGW 和 Cygwin 下轻松构建不需要控制台窗口的程序。

Cygwin is not strictly POSIX. In addition to providing access to the Windows API, it also provides its own implementations of some Microsoft C functions (stuff found in msvcrt.dllor the re-distributable msvcrtnn.dllrun-times). An example of this are the spawn*family of functions like spawnvp. These are a good idea to use instead of forkand execon Cygwin since they map better to the Windows process creation model which has no concept of fork.

Cygwin 不是严格的 POSIX。除了提供对 Windows API 的访问之外,它还提供了自己的一些 Microsoft C 函数的实现(在msvcrt.dll或可重新分发的msvcrtnn.dll运行时中找到的东西)。这方面的一个例子是spawn*spawnvp. 这是使用,而不是一个好主意,fork而且exec,因为他们更好地映射到不具有的概念在Windows进程创建的模型在Cygwin fork

Thus:

因此:

  • Cygwin programs are no less "native" than MS Visual C programs on grounds of requiring the accompaniment of libraries. Programming language implementations on Windows are expected to provide their own run-time, even C language implementations. There is no "libc" on Windows for public use.

  • The fact that MinGW requires no third-party DLL is actually a disadvantage; it is depending on an undocumented, Windows-internal fork of the Visual C run-time. MinGW does this because the GPL system library exception applies to msvcrt.dll, which means that GPL-ed programs can be compiled and redistributed with MinGW.

  • Due to its much broader and deeper support for POSIX compared to msvcrt.dll, Cygwin is by far the superior environment for porting POSIX programs. Since it is now under the LGPL, it allows applications with all sorts of licenses, open or closed source, to be redistributed. Cygwin even contains VT100 emulation and termios, which work with the Microsoft console! A POSIX application that sets up raw mode with tcsetattrand uses VT100 codes to control the cursor will work right in the cmd.exewindow. As far as the end-user is concerned, it's a native console app making Win32 calls to control the console.

  • Cygwin 程序与 MS Visual C 程序一样“本机”,因为它需要库的伴奏。Windows 上的编程语言实现应该提供自己的运行时,甚至是 C 语言实现。Windows 上没有供公共使用的“libc”。

  • MinGW 不需要第三方 DLL 的事实实际上是一个缺点;它依赖于 Visual C 运行时的一个未记录的 Windows 内部分支。MinGW 这样做是因为 GPL 系统库例外适用于msvcrt.dll,这意味着 GPL-ed 程序可以用 MinGW 编译和重新分发。

  • 由于与msvcrt.dll. 由于它现在在 LGPL 之下,它允许重新分发具有各种许可证的应用程序,无论是开源的还是闭源的。 Cygwin 甚至包含 VT100 仿真和termios,可与 Microsoft 控制台一起使用!tcsetattr使用 VT100 代码设置原始模式并使用 VT100 代码控制光标的 POSIX 应用程序将在cmd.exe窗口中正常工作。就最终用户而言,它是一个本地控制台应用程序,通过 Win32 调用来控制控制台。

However:

然而:

  • As a native Windows development tool, Cygwin has some quirks, like path handling that is foreign to Windows, dependence on some hard-coded paths like /bin/shand other issues. These differences are what render Cygwin programs "non-native". If a program takes a path as an argument, or input from a dialog box, Windows users expect that path to work the same way as it does in other Windows programs. If it doesn't work that way, that's a problem.
  • 作为本机 Windows 开发工具,Cygwin 有一些怪癖,例如 Windows 不熟悉的路径处理、对某些硬编码路径的依赖/bin/sh以及其他问题。这些差异使 Cygwin 程序“非本地”。如果程序将路径作为参数或从对话框中输入,Windows 用户希望该路径的工作方式与其他 Windows 程序中的工作方式相同。如果它不能那样工作,那就是一个问题。

Plug:Shortly after the LGPL announcement, I started the Cygnal(Cygwin Native Application Library) project to provide a fork of the Cygwin DLL which aims to fix these issues. Programs can be developed under Cygwin, and then deployed with the Cygnal version of cygwin1.dllwithout recompiling. As this library improves, it will gradually eliminate the need for MinGW.

Plug:在 LGPL 宣布后不久,我启动了Cygnal(Cygwin 本地应用程序库)项目,以提供旨在解决这些问题的 Cygwin DLL 的分支。程序可以在 Cygwin 下开发,然后用 Cygnal 版本部署,cygwin1.dll无需重新编译。随着这个库的改进,它将逐渐消除对 MinGW 的需求。

When Cygnal solves the path handling problem, it will be possible to develop a single executable which works with Windows paths when shipped as a Windows application with Cygnal, and seamlessly works with Cygwin paths when installed in your /usr/binunder Cygwin. Under Cygwin, the executable will transparently work with a path like /cygdrive/c/Users/bob. In the native deployment where it is linking against the Cygnal version of cygwin1.dll, that path will make no sense, whereas it will understand c:foo.txt.

当 Cygnal 解决了路径处理问题时,就可以开发一个单独的可执行文件,当作为 Windows 应用程序与 Cygnal 一起提供时,该可执行文件可以与 Windows 路径一起使用,并且在安装在/usr/binCygwin 下时可以与 Cygwin 路径无缝协作。在 Cygwin 下,可执行文件将透明地使用类似/cygdrive/c/Users/bob. 在与 Cygnal 版本链接的本机部署中cygwin1.dll,该路径将毫无意义,而它会理解c:foo.txt.

回答by PersianGulf

Wikipedia Says:

维基百科说

MinGWforked from version 1.3.3 of Cygwin. Although both Cygwinand MinGWcan be used to port UNIXsoftware to Windows, they have different approaches: Cygwinaims to provide a complete POSIX layerthat provides emulations of several system calls and libraries that exist on Linux, UNIX, and the BSDvariants. The POSIX layerruns on top of Windows, sacrificing performance where necessary for compatibility. Accordingly, this approach requires Windowsprograms written with Cygwinto run on top of a copylefted compatibility library that must be distributed with the program, along with the program's source code. MinGWaims to provide native functionality and performance via direct Windows API calls. Unlike Cygwin, MinGWdoes not require a compatibility layer DLLand thus programs do not need to be distributed with source code.

Because MinGWis dependent upon Windows API calls, it cannot provide a full POSIX API; it is unable to compile some UNIX applicationsthat can be compiled with Cygwin. Specifically, this applies to applications that require POSIXfunctionality like fork(), mmap()or ioctl()and those that expect to be run in a POSIX environment. Applications written using a cross-platform librarythat has itself been ported to MinGW, such as SDL, wxWidgets, Qt, or GTK+, will usually compile as easily in MinGWas they would in Cygwin.

The combination of MinGWand MSYSprovides a small, self-contained environment that can be loaded onto removable media without leaving entries in the registry or files on the computer. CygwinPortable provides a similar feature. By providing more functionality, Cygwinbecomes more complicated to install and maintain.

It is also possible to cross-compile Windows applicationswith MinGW-GCC under POSIX systems. This means that developers do not need a Windows installation with MSYSto compile software that will run on Windowswithout Cygwin.

MinGW从 1.3.3 版分叉出来Cygwin。虽然两者CygwinMinGW可以用于端口UNIX的软件Windows,它们有不同的方法:Cygwin旨在提供一个完整的POSIX layer,它提供的几个系统调用,并且存在于库仿真LinuxUNIXBSD变种。在POSIX layer之上运行Windows,牺牲性能在必要的兼容性。因此,这种方法要求 Windows编写的程序Cygwin运行在必须与程序一起分发的 Copyleft 兼容库之上,以及程序的source code. MinGW旨在通过直接提供本机功能和性能Windows API calls。不像 CygwinMinGW不需要兼容层DLL,因此程序不需要与source code.

因为MinGW是依赖Windows API calls,所以不能提供完整的POSIX API;它无法编译一些UNIX applications可以用Cygwin. 具体而言,这适用于需要的应用程序POSIX一样的功能 fork()mmap()ioctl()和那些希望在运行 POSIX environment。使用cross-platform library本身已被移植到的a 编写的应用程序MinGW,例如SDL, wxWidgets, Qt, or GTK+,通常会像在 中MinGW一样容易编译 Cygwin

的组合MinGW,并MSYS提供了一个可以装载到可移动媒体不留在计算机上的注册表项或文件小,独立的环境。Cygwin便携式提供了类似的功能。通过提供更多功能,Cygwin安装和维护变得更加复杂。

也可以cross-compile Windows applicationsMinGW-GCC under POSIX systems. 这意味着开发人员无需安装 WindowsMSYS即可编译Windows无需Cygwin.

回答by Norman Ramsey

Don't overlook AT&T's U/Winsoftware, which is designed to help you compile Unix applications on windows (last version - 2012-08-06; uses Eclipse Public License, Version 1.0).

不要忽视AT&T 的U/Win软件,它旨在帮助您在 Windows 上编译 Unix 应用程序(最新版本 - 2012-08-06;使用 Eclipse 公共许可证,版本 1.0)。

Like Cygwin they have to run against a library; in their case POSIX.DLL. The AT&T guys are terrific engineers (same group that brought you ksh and dot) and their stuff is worth checking out.

像 Cygwin 一样,它们必须与库运行;在他们的情况下POSIX.DLL。AT&T 的人是了不起的工程师(为您带来了 ksh 和dot 的同一组),他们的东西值得一试。

回答by smwikipedia

Other answers already hit the target. I just want to add an illustration for a quick catch.

其他答案已经达到了目标。我只想添加一个插图以便快速了解。

enter image description here

在此处输入图片说明