为什么GCC-Windows依赖于cygwin? [英] Why does GCC-Windows depend on cygwin?

查看:144
本文介绍了为什么GCC-Windows依赖于cygwin?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是一个C ++开发人员,但我一直对编译器感兴趣,我有兴趣修改一些GCC的东西(特别是LLVM)。

I'm not a C++ developer, but I've always been interested in compilers, and I'm interested in tinkering with some of the GCC stuff (particularly LLVM).

在Windows上,GCC需要POSIX仿真层(cygwin或MinGW)才能正常运行。

On Windows, GCC requires a POSIX-emulation layer (cygwin or MinGW) to run correctly.

为什么?

我使用许多其他软件,用C ++编写,并为不同的平台(Subversion,Firefox,Apache,MySQL)交叉编译,并且没有一个需要cygwin或MinGW。

I use lots of other software, written in C++ and cross-compiled for different platforms (Subversion, Firefox, Apache, MySQL), and none of them require cygwin or MinGW.

我对C ++最佳实践编程的理解是,您可以编写合理的平台中性代码,并在编译过程中处理所有的差异。

My understanding about C++ best-practice programming is that you can write reasonably platform-neutral code and deal with all the differences during the compilation process.

那么与GCC有什么关系呢?为什么不能在Windows上本机运行?

So what's the deal with GCC? Why can't it run natively on Windows?

编辑:

好了,到目前为止的两个回复基本上说,GCC使用posix层,因为它使用posix头。

Okay, the two replies so far say, basically, "GCC uses the posix layer because it uses the posix headers".

但这不真正回答

假设我已经为我最喜欢的标准库设置了一组标题。为什么还需要posix标头?

Let's say I already have a set of headers for my favorite standard library. Why would I still need the posix headers?

GCC是否需要cygwin / mingw才能实际运行?

Does GCC require cygwin/mingw to actually RUN?

还是只需要头和库的仿真层?如果是,为什么我不能给它一个lib目录所需的资源?

Or does it only need the emulation layer for headers and libraries? If so, why can't I just give it a "lib" directory with the required resources?

好的,我会再试一次澄清这个问题...

Okay, I'll try again to clarify the question...

a href =http://digitalmars.com/d =nofollow noreferrer> D编程语言。官方编译器名为dmd,并且有Windows和linux的官方编译器二进制文件。

I also write code in the D Programming Language. The official compiler is named "dmd" and there are official compiler binaries for both Windows and linux.

Windows版本不需要任何类型的POSIX仿真。而Linux版本不需要任何类型的Win32仿真。如果编译器有关于它的环境的假设,它隐藏这些假设很好。

The Windows version doesn't require any kind of POSIX emulation. And the Linux version doesn't require any kind of Win32 emulation. If the compiler has assumptions about its environment, it hides those assumptions pretty well.

当然,我必须告诉编译器在哪里找到标准库和在哪里找到图书馆以静态或动态链接。

Of course, I have to tell the compiler where to find the standard library and where to find libraries to statically or dynamically link against.

相反,GCC坚持假装它在posix环境中操作,并要求ME幽默这些假设,仿真层。

GCC, by contrast, insists on pretending it's operating within a posix environment, and it asks ME to humor those assumptions by setting up an emulation layer.

但是,究竟是什么,GCC依赖于该层?它只是在寻找stdlib头,它假设它会在/ usr / lib中找到这些头?

But what, exactly, within GCC relies on that layer? Is it just looking for stdlib headers, and it assumes it'll find those headers within "/usr/lib"?

如果是这样,我不应该能够让它在C:/ gcc / lib中查找这些头文件吗?

If that's the case, shouldn't I just be able to tell it to look in "C:/gcc/lib" to find those header files?

或者GCC本身依赖于POSIX库来访问文件系统(和做其他低级东西)?如果是这样,那么我想知道为什么他们不只是静态链接到他们喜欢的Windows POSIX库。为什么要求用户设置依赖关系,当他们可以在应用程序中构建这些依赖关系?

Or does GCC itself rely on the POSIX libraries to access the file system (and to do other low-level stuff)? If that's the case, then I wonder why they don't just statically link with their favorite windows POSIX libraries. Why require the user to set up the dependencies, when they could build those dependencies right into the application?

推荐答案

前提是错误的: MinGW GCC 需要Cygwin。

Actually, the question premise is wrong: MinGW GCC does NOT require Cygwin.

你会看到你根本不需要Cygwin。它在Windows上本机运行(至少32位)。工具链和生成的二进制文件与Cygwin无关。

You will see you don't need Cygwin at all. It runs natively on Windows (32-bit, at least). Both the toolchain and the produced binaries are independent of Cygwin.

Cygwin中提供的MinGW编译器是不同的:它们是建立在Cygwin平台上的,依赖于Cygwin运行时。编译器本身在这种情况下依赖于Cygwin。但是这是因为你从Cygwin安装了它们。

The MinGW compilers available in Cygwin are different: they are built on the Cygwin platform, to generate code which does not depend on the Cygwin runtime. The compilers themselves do depend on Cygwin in that case. But that's because you installed them from Cygwin.

这篇关于为什么GCC-Windows依赖于cygwin?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆