macos Mac OS X 免费的 C 编译器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1052844/
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
Mac OS X free C compiler
提问by Matthew Scharley
Is there a small, free C or C++ compiler for OS X, like TCC?
是否有适用于 OS X 的小型免费 C 或 C++ 编译器,例如 TCC?
Xcode is not small, or simple like TCC, AFAIK.
Xcode 并不小,或者像 TCC、AFAIK 一样简单。
I'm looking for something like a GCC binary file or TCC for OS X.
我正在寻找像 GCC 二进制文件或 OS X 的 TCC 之类的东西。
回答by Matthew Scharley
gccis the most widely used one (and Apple provides official builds of it as part of XCode). XCode is also usually distributed on your OS X cd's, though that version may be a little out of date now, depending on what version of OS X you have.
gcc是使用最广泛的一种(Apple 提供了它的官方版本作为 XCode 的一部分)。XCode 通常也分发在您的 OS X 光盘上,尽管该版本现在可能有点过时,具体取决于您拥有的 OS X 版本。
For information and samples on how to use it, look here.
Look into Finkor one of the similar projectsout there if you want a build of gcc that's not linked to Xcode. That said though, Xcode is a great IDE for OS X.
如果您想要构建未链接到 Xcode 的 gcc,请查看Fink或类似的项目之一。尽管如此,Xcode 是适用于 OS X 的出色 IDE。
回答by Frank V
I know you want a small compiler, but it is best to just download and install Xcode. It is a great IDE. From there, you don't have to use it if you don't want to. Once it is installed, you can use something like this in terminal:
我知道您想要一个小型编译器,但最好只下载并安装 Xcode。这是一个很棒的IDE。从那里开始,如果您不想,则不必使用它。安装后,您可以在终端中使用以下内容:
gcc myFile.c -o myFile
And that would build a source file called myFile.c which contains C code and the output module (executable) would be myFile
. You'd execute it by running:
这将构建一个名为 myFile.c 的源文件,其中包含 C 代码和输出模块(可执行文件)将是myFile
. 你可以通过运行来执行它:
./myFile
Update: What is your reason for not wanting Xcode? Furthermore, is GCCitself ok (disregarding Xcode for a moment)? It's important to know that GCC is not a part of Xcode. Apple made use of GCC, which is an open source C/C++ (and more) compiler.
更新:您不想要 Xcode 的原因是什么?此外,GCC本身是否可以(暂时忽略 Xcode)?重要的是要知道 GCC 不是 Xcode 的一部分。Apple 使用了GCC,这是一个开源 C/C++(以及更多)编译器。
I just can't find binaries of GCC for mac so downloading Xcode is an easy way to get some...
我只是找不到适用于 mac 的 GCC 二进制文件,因此下载 Xcode 是获取一些...的简单方法。
Update 2: It also just came to my attention that NetBeans will compile C / C++ Code. It also uses the GCC compiler. I'm not sure if it using GCCfrom my Xcode installation but I thought I'd mention this.
更新 2:我也注意到 NetBeans 将编译 C/C++ 代码。它还使用GCC 编译器。我不确定它是否从我的 Xcode 安装中使用GCC,但我想我会提到这一点。
Best Regards,
Frank
最好的问候,
弗兰克
回答by Louis Davis
You could use the Xcode Tools that are already included in OSX.
您可以使用 OSX 中已包含的 Xcode 工具。
Xcodeis the same professional developer toolset used by Apple to create Mac OS X, as well as many great Apple applications, and Xcode is included with every copy of Mac OS X.
Xcode与 Apple 用来创建 Mac OS X 以及许多出色的 Apple 应用程序的专业开发人员工具集相同,并且 Xcode 包含在每个 Mac OS X 副本中。
回答by theCakeCoder
You can use Code::Blocks IDEits simple slick and hav good set of feture, a plus opensurce and ready to dl for 3 major plateforms
您可以使用Code::Blocks IDE其简单的圆滑和良好的功能集,加上 opensurce 并准备 dl 用于 3 个主要平台
still recoment using Xcode if u just have to make projects for MAC, but if u are going to port it to linux and windows, then my choice is Code::Blocks [Give it a try atleast]
如果您只需要为 MAC 制作项目,仍然建议使用 Xcode,但如果您要将其移植到 linux 和 windows,那么我的选择是 Code::Blocks [至少尝试一下]
回答by mkb
回答by Pratik
PCC, the Portable C Compiler, is available for the Mac. It is small and free. Its tarball weighs in at total of 1778 KB from its 4th of July CVS Snapshot.
PCC,便携式 C 编译器,可用于 Mac。它小而免费。从 7 月 4 日的 CVS 快照来看,它的 tarball 总共有 1778 KB。
回答by Janusz
If you don't want to use Xcode install the macports from macports.organd if you like a graphical user interface install porticusas a managment gui for all the installed ports. In Porticus you can now easily install all different versions of gcc without Xcode. Porticus will compile the packages for your mac and install all the needed dependencies like a Linux packet manager.
如果您不想使用 Xcode,请从macports.org安装macports,如果您喜欢图形用户界面,请安装porticus作为所有已安装端口的管理 gui。在 Porticus 中,您现在无需 Xcode 即可轻松安装所有不同版本的 gcc。Porticus 将为您的 mac 编译软件包并安装所有需要的依赖项,如 Linux 数据包管理器。