How do I install g++ on MacOS X?(如何在 MacOS X 上安装 g++?)
问题描述
我想在 MacOS X 上使用 g++ 编译器编译 C++ 代码.如何安装?
I want to compile C++ code on MacOS X, using the g++ compiler. How do I install it?
推荐答案
这是苹果XCode工具包自带的编译器.他们已经破解了一点,但基本上它只是 g++.
That's the compiler that comes with Apple's XCode tools package. They've hacked on it a little, but basically it's just g++.
您可以在此处免费下载 XCode(嗯,大多数情况下,您必须注册成为 ADC 成员,但这也是免费的):http://developer.apple.com/technology/xcode.html
You can download XCode for free (well, mostly, you do have to sign up to become an ADC member, but that's free too) here: http://developer.apple.com/technology/xcode.html
编辑 2013-01-25:这个答案在 2010 年是正确的.它需要更新.
Edit 2013-01-25: This answer was correct in 2010. It needs an update.
虽然 XCode 工具仍然有一个命令行 C++ 编译器,但在最近的 OS X 版本(我认为是 10.7 及更高版本)中已切换到 clang/llvm(主要是因为 Apple 想要开源的所有好处而无需回馈,并且 clang 是 BSD 许可的).其次,我认为安装 XCode 所需要做的就是从 App Store 下载它.我很确定那里是免费的.
While XCode tools still has a command-line C++ compiler, In recent versions of OS X (I think 10.7 and later) have switched to clang/llvm (mostly because Apple wants all the benefits of Open Source without having to contribute back and clang is BSD licensed). Secondly, I think all you have to do to install XCode is to download it from the App store. I'm pretty sure it's free there.
因此,为了获得 g++,您必须使用 homebrew 之类的东西(似乎是当前的安装方式Mac 上的开源软件(尽管 homebrew使用它安装 gcc 有很多注意事项)),fink(基本上是 Debian 的 apt 系统OS X/Darwin)或 MacPorts(基本上是 OS X/Darwin 的 OpenBSDs 端口系统)来获取它.
So, in order to get g++ you'll have to use something like homebrew (seemingly the current way to install Open Source software on the Mac (though homebrew has a lot of caveats surrounding installing gcc using it)), fink (basically Debian's apt system for OS X/Darwin), or MacPorts (Basically, OpenBSDs ports system for OS X/Darwin) to get it.
Fink 肯定有合适的软件包.在 2016-12-26,它有 gcc 5 和 gcc 6 包.
Fink definitely has the right packages. On 2016-12-26, it had gcc 5 and gcc 6 packages.
我对 MacPorts 的工作原理不太熟悉,尽管一些初步的粗略调查表明他们也有相关的软件包.
I'm less familiar with how MacPorts works, though some initial cursory investigation indicates they have the relevant packages as well.
这篇关于如何在 MacOS X 上安装 g++?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 MacOS X 上安装 g++?
基础教程推荐
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- CString 到 char* 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
