C语言 什么是MinGW的简单解释

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7790262/
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-02 09:55:24  来源:igfitidea点击:

A simple explanation of what is MinGW

cwindowsgcccygwinmingw

提问by Mridang Agarwalla

I'm an avid Python user and it seems that I require MinGW to be installed on my Windows machine to compile some libraries. I'm a little confused about MinGW and GCC. Here's my question (from a real dummy point of view):

我是一个狂热的 Python 用户,似乎我需要在我的 Windows 机器上安装 MinGW 来编译一些库。我对 MinGW 和 GCC 有点困惑。这是我的问题(从真正的虚拟角度来看):

So Python is language which both interpreted and compiled. There are Linux and Windows implementations of Python which one simply installs and used the binary to a execute his code. They come bundled with a bunch of built-in libraries that you can use. It's the same with Ruby from what I've read.

所以Python是一种既解释又编译的语言。有 Python 的 Linux 和 Windows 实现,可以简单地安装并使用二进制文件来执行他的代码。它们捆绑了一堆您可以使用的内置库。从我读过的内容来看,Ruby 也是如此。

Now, I've done a tiny bit a of C and I know that one has a to compile it. It has its built-in libraries which seem to be called header files which you can use. Now, back in the school day's, C, was writing code in a vi-like IDE called Turbo-C and then hitting F9 to compile it. That's pretty much where my C education ends.

现在,我已经做了一点点 C 并且我知道有人可以编译它。它有它的内置库,这些库似乎被称为您可以使用的头文件。现在,回到学生时代,C 正在一个名为 Turbo-C 的类似 vi 的 IDE 中编写代码,然后按 F9 进行编译。这几乎是我的 C 教育结束的地方。

What is MinGW and what is GCC? I've been mainly working on Windows systems and have even recently begun using Cygwin. Aren't they the same?

什么是 MinGW,什么是 GCC?我一直主要在 Windows 系统上工作,甚至最近开始使用 Cygwin。他们不是一样的吗?

A simple explanation hitting these areas would be helpful.

对这些区域进行简单的解释会有所帮助。

(My apologies if this post sounds silly/stupid. I thought I'd ask here. Ignoring these core bits never made anyone a better programmer.)

(如果这篇文章听起来很傻/愚蠢,我很抱歉。我想我会在这里问。忽略这些核心部分永远不会让任何人成为更好的程序员。)

Thanks everyone.

谢谢大家。

采纳答案by Damon

MinGW is a complete GCC toolchain (including half a dozen frontends, such as C, C++, Ada, Go, and whatnot) for the Windows platform which compiles for and links to the Windows OS component C Runtime Library in msvcrt.dll. Rather it tries to be minimal(hence the name).

MinGW 是一个完整的 GCC 工具链(包括六个前端,如 C、C++、Ada、Go 等),用于 Windows 平台,它编译并链接到 msvcrt.dll 中的 Windows 操作系统组件 C 运行时库。相反,它试图最小化(因此得名)。

This means, other than Cygwin, MinGW does notattempt to offer a complete POSIX layer on top of Windows, but on the other hand it does not require you to link with a special compatibility library.
It therefore also does nothave any GPL-license implications for the programs you write (notable exception: profiling libraries, but you will not normally distribute those so that does not matter).

这意味着,除了 Cygwin,MinGW不会尝试在 Windows 之上提供完整的 POSIX 层,但另一方面,它不需要您链接特殊的兼容性库。
因此,它对您编写的程序也没有任何 GPL 许可证的影响(值得注意的例外:分析库,但您通常不会分发这些库,因此这无关紧要)。

The newer MinGW-w64 comes with a roughly 99% complete Windows API binding (excluding ATL and such) including x64 support and experimental ARM implementations. You may occasionally find some exotic constant undefined, but for what 99% of the people use 99% of the time, it just works perfectly well.

较新的 MinGW-w64 带有大约 99% 完整的 Windows API 绑定(不包括 ATL 等),包括 x64 支持和实验性 ARM 实现。您可能偶尔会发现一些未定义的奇异常数,但对于 99% 的人在 99% 的时间里使用的东西,它运行得非常好。

You can also use the bigger part of what's in POSIX, as long as it is implemented in some form under Windows. The one major POSIX thing that does not work with MinGW is fork, simply because there is no such thing under Windows (Cygwin goes through a lot of pain to implement it).
There are a few other minor things, but all in all, most things kind of work anyway.

您还可以使用 POSIX 中的大部分内容,只要它在 Windows 下以某种形式实现即可。与 MinGW 不兼容的一个主要 POSIX 事情是fork,仅仅因为在 Windows 下没有这样的事情(Cygwin 经历了很多痛苦来实现它)。
还有一些其他的小事情,但总的来说,大多数事情无论如何都是有效的。

So, in a very very simplified sentence: MinGW(-w64) is a "no-frills compiler thingie" that lets you write native binary executables for Windows, not only in C and C++, but also other languages.

所以,用一个非常非常简单的句子:MinGW(-w64) 是一个“简洁的编译器”,它允许您为 Windows 编写本机二进制可执行文件,不仅可以使用 C 和 C++,还可以使用其他语言。

回答by pmg

To compile C program you need a C implementationfor your specific computer.

要编译 C 程序,您需要针对特定计算机的C 实现

C implementations consist, basically, of a compiler (its preprocesser and headers) and a library (the ready-made executable code).

C 实现基本上由一个编译器(它的预处理器和头文件)和一个库(现成的可执行代码)组成。

On a computer with Windows installed, the library that contains most ready-made executable code is not compatible with gcccompiler ... so to use this compiler in Windows you need a different library: that's where MinGWenters. MinGWprovides, among other things, the library(ies) needed for making a C implementation together with gcc.

在安装了 Windows 的计算机上,包含大多数现成可执行代码的库与gcc编译器不兼容……因此要在 Windows 中使用此编译器,您需要一个不同的库:这就是MinGW进入的地方。MinGW除其他外,还提供了与gcc.



The Windows library and MSVC together make a different implementation.

Windows 库和 MSVC 共同构成了不同的实现。

回答by Fran Borcic

MinGW is an implementation of most of the GNU building utilities, like gcc and make on windows, while gcc is only the compiler. Cygwin is a lot bigger and sophisticated package, wich installs a lot more than MinGW.

MinGW 是大多数 GNU 构建实用程序的实现,例如 Windows 上的 gcc 和 make,而 gcc 只是编译器。Cygwin 是一个更大更复杂的包,比 MinGW 安装的要多得多。

回答by MVS

MinGW is a suite of development tools that contains GCC (among others), and GCC is a C compiler within that suite.

MinGW 是一套包含 GCC(以及其他)的开发工具,而 GCC 是该套件中的 C 编译器。

回答by Real Name

The only reason for existence of MinGW is to provide linux-like environment for developers not capable of using native windows tools. It is inferior in almost every respect to Microsoft tooolchains on Win32/Win64 platforms, BUT it provides environment where linux developer does not have to learn anything new AND he/she can compile linux code almost without modifications. It is a questionable approach , but many people find that convenience more important than other aspects of the development . It has nothing to do with C or C++ as was indicated in earlier answers, it has everything to do with the environment developer wants. Argument about GNU toolchains on windows and its nessessety, is just that - an argument

MinGW 存在的唯一原因是为无法使用本机 Windows 工具的开发人员提供类似 linux 的环境。它在 Win32/Win64 平台上几乎在各个方面都不如 Microsoft 工具链,但它提供了 linux 开发人员不必学习任何新东西并且他/她几乎无需修改即可编译 linux 代码的环境。这是一个值得商榷的方法,但很多人发现,方便比开发的其他方面更重要。正如前面的答案中所指出的,它与 C 或 C++ 无关,它与开发人员想要的环境有关。关于 Windows 上的 GNU 工具链及其必要性的争论就是这样 - 一个争论

GCC - unix/linux compiler, MinGW - approximation of GCC on Windows environment, Microsoft compiler and Intel compiler - more of the same as names suggest(both produce much , much better programs on Windows then MinGW, btw)

GCC - unix/linux 编译器,MinGW - Windows 环境下 GCC 的近似值,Microsoft 编译器和 Intel 编译器 - 顾名思义(两者在 Windows 上生成的程序比 MinGW 好得多,顺便说一句)