macos 有没有办法在不安装 Xcode 的情况下在 OSX 中安装 gcc?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/114884/
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
Is there a way to install gcc in OSX without installing Xcode?
提问by aryo
I've googled the hell out of it, and it seems like there is no way to install gcc on OS X without installing Xcode (which takes at leats 1.5GB of space). All I need is gcc and none of the other junk that comes with Xcode. And at this point, I'll take any other kind of C compiler.
我已经用谷歌搜索了它,似乎没有办法在 OS X 上安装 gcc 而不安装 Xcode(这需要至少 1.5GB 的空间)。我所需要的只是 gcc 而不是 Xcode 附带的任何其他垃圾。在这一点上,我将采用任何其他类型的 C 编译器。
I know I could simply install Xcode, but that is beside the point since I neither have my original installation disc nor a quick internet connection.
我知道我可以简单地安装 Xcode,但这不是重点,因为我既没有原始安装光盘,也没有快速的互联网连接。
So... does anyone have any suggestions?
所以……有人有什么建议吗?
EDIT: Sorry if I was unclear, but I need the headers as well. I'm currently installing gcc4 via fink and it's downloading the shared libraries as well. I'll update on the progress.
编辑:对不起,如果我不清楚,但我也需要标题。我目前正在通过 fink 安装 gcc4,它也在下载共享库。我会更新进度。
EDIT 2: Ok, so I successfully installed gcc using fink. BUT, it's pretty much useless: "error: C compiler cannot create executables". After googling around, I found that not having Apple's Developer Tools installed is the cause of the error. Probably because I need all the libraries, headers, etc that are only available through Xcode.
编辑 2:好的,所以我使用 fink 成功安装了 gcc。但是,它几乎没用:“错误:C 编译器无法创建可执行文件”。谷歌搜索后,我发现没有安装 Apple 的开发者工具是导致错误的原因。可能是因为我需要所有只能通过 Xcode 获得的库、头文件等。
采纳答案by ergosys
Try the osx-gcc-installeron github.
试试github 上的 osx-gcc-installer。
回答by Amir Raminfar
Checkout command line toolsfor Xcode from apple. It's official support from apple to only create the command line tools.
回答by Tom Swirly
I've been doing this for a long time, and I've done things like this, and I've concluded it's simply never worth doing. :-(
我已经这样做了很长时间,我也做过这样的事情,我得出的结论是它根本不值得做。:-(
The reason is that no one expects you to do such things, so there are assumptions all over the system that "everything" is there. You might not run into this today - or worse, you might not even realize later that this is the cause of your issues.
原因是没有人期望你做这样的事情,所以整个系统都假设“一切”都在那里。您今天可能不会遇到这种情况 - 或者更糟的是,您以后甚至可能没有意识到这是导致您出现问题的原因。
Instead of wasting your smart time on things like this which don't actually produce any working code you can use, following the approved method, run the download overnight, and spend your time instead on planning and writing the top-level code (you shouldn't need a compiler for that anyway!)
与其将你的聪明时间浪费在这些实际上不会产生任何你可以使用的工作代码的事情上,不如按照批准的方法,在一夜之间运行下载,然后把你的时间花在计划和编写顶级代码上(你应该无论如何都不需要编译器!)
回答by Tim Visher
I'm fairly certain that this is not possible. However, I'm also not sure if you need the whole developer suite to get the developer tools installed. Quite a few tools get installed along with XCode that might be optional. However, I think you're out of luck for not needing to bite the bullet and use wget or DownThemAll or some other download manager that will let you slowly download the developer tools in chunks.
我相当肯定这是不可能的。但是,我也不确定您是否需要整个开发人员套件来安装开发人员工具。相当多的工具与 XCode 一起安装,它们可能是可选的。但是,我认为您不走运,因为不需要硬着头皮使用 wget 或 DownThemAll 或其他一些下载管理器,它们可以让您慢慢地分块下载开发人员工具。
Whenever I install OS X I install the developer tools as a rule, just because it opens up the world of available software tremendously. Perhaps you should consider doing this in the future as well.
每当我安装 OS XI 时,通常都会安装开发人员工具,因为它极大地打开了可用软件的世界。也许您将来也应该考虑这样做。
回答by Mike Heinz
The first thing you want to try is called Pacifist- what Pacifist lets you do is to open a large package (such as XCode) and to access parts of it directly. I'm pretty sure you'll be able to find a smaller package inside the XCode package that just has gcc.
您想要尝试的第一件事称为Pacifist- Pacifist 让您做的是打开一个大包(例如 XCode)并直接访问其中的一部分。我很确定您将能够在只有 gcc 的 XCode 包中找到一个较小的包。
HOWEVERit's not clear to me that this is the best route. If you are planning to do Cocoa or Carbon developing I stronglysuggest installing the entire package because you will need all the documentation and headers. If you're only planning on doing command-line stuff, you still may find you need to poke around inside XCode to identify all the packages you will need - things such as libraries, headers, man pages and so on.
然而,我不清楚这是最好的路线。如果您打算进行 Cocoa 或 Carbon 开发,我强烈建议您安装整个软件包,因为您将需要所有文档和标题。如果你只打算做命令行的东西,你仍然可能会发现你需要在 XCode 内部四处看看来确定你需要的所有包——比如库、标题、手册页等。
All in all you're probably still better off installing the whole thing - if HD space is really tight (because you're on a tiny old iMac for example) then look at tools like Monolingual- Monolingual removes all the international support from all the various OS X applications, which can easily reduce the size of an application by 50%.
总而言之,您最好安装整个设备 - 如果 HD 空间非常紧张(例如,因为您使用的是小型旧 iMac),那么请查看诸如Monolingual 之类的工具- Monolingual 删除了所有的国际支持各种 OS X 应用程序,可以轻松地将应用程序的大小减少 50%。
回答by eduffy
There's fink and MacPorts, if you want an easy installer/updater.
如果您想要一个简单的安装程序/更新程序,可以使用 fink 和 MacPorts。
回答by millenomi
Install the GCC package from the Packages directory in Xcode's disk image and you'll have just GCC. Note that of course you won't have autotools or other standard build tools, for which you will have to install more packages from that folder.
从 Xcode 磁盘映像中的 Packages 目录安装 GCC 包,您将只拥有 GCC。请注意,您当然不会拥有 autotools 或其他标准构建工具,因此您必须从该文件夹安装更多软件包。
回答by Brian
回答by xjzhou
install Command Line Tool separately.
单独安装命令行工具。
refer to
参考