从Mac上的文件将G ++安装到终端 [英] Installing g++ to terminal from files on my mac

查看:56
本文介绍了从Mac上的文件将G ++安装到终端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在Mac终端中编译c ++程序时,出现以下错误:

When I try to compile a c++ program in my Mac terminal, I get the following error:

-bash:g ++:找不到命令

-bash: g++: command not found

但是我相信我拥有Mac上运行编译器所需的所有文件.我有Developer文件夹,其中包含Applications中的Xcode,usr/bin文件夹中的g ++和其他文件夹.

but I believe I have all the files I need on my Mac to run the compiler. I have the Developer folder, which contains Xcode in Applications, g++ in the usr/bin folder, and a bunch of other folders.

如何使用这些文件安装g ++编译器.谢谢!

How can I use these files to install the g++ compiler. Thank you!

推荐答案

houbysoft的答案是正确的,但是OP需要更多细节.

houbysoft's answer above is correct, but the OP needs a little more detail.

基本思想是您需要安装命令行工具"环境.但是,多年来,该环境的名称及其安装方式已多次更改.因此,houbysoft的步骤适用于4.3.3,但不适用于3.2.6.

The basic idea is that you need the "Command Line Tools" environment installed. But the name for that environment, and how you install it, has changed multiple times over the years. So, houbysoft's steps work for 4.3.3, but not for 3.2.6.

在3.2时代,这些工具被称为"UNIX开发".而且,它们不是从Xcode内下载和安装,而是作为Xcode mpkg的一部分并作为初始Xcode安装的一部分安装的.在大多数版本中,都有一个名为"UNIX开发"的复选框,通常默认情况下会选中该复选框,但是在某些版本中,这是一个单独的步骤.查看当前可从Apple获得的"Xcode 3.2.6和IOS SDK 4.3"磁盘映像,这是一个复选框.无论如何,这是获得官方支持的唯一方法,但是还有许多其他方法可以工作……这是您的选择:

In the 3.2 era, the tools were called "UNIX Development". And, rather than being downloaded and installed from within Xcode, they came as part of the Xcode mpkg and were installed as part of the initial Xcode install. In most versions, there was a checkbox named "UNIX Development", usually checked by default, but in some versions it was a separate step. Looking at the "Xcode 3.2.6 and IOS SDK 4.3" disk image currently available from Apple, it's a checkbox. Anyway, that's the only officially-supported way to get them, but lots of other ways work… Here are your options:

  • 扔掉Xcode 3.2.6(将整个/Developer丢掉)并安装4.3.3,然后按照houbysoft的步骤获得命令行工具.除非有充分的理由不能使用4.3,否则几乎可以肯定这是最好的答案.
  • 扔掉Xcode 3.2.6并重新安装它,这次确保"UNIX Development"复选框已打开.
  • 只需重新运行3.2.6安装程序,并确保"UNIX开发"复选框处于启用状态.
  • 登录developer.apple.com并浏览下载的软件包,该软件包名为"UNIX开发工具",开发人员工具CLI","CLI开发人员环境",命令行工具"或与3.2相对应的类似软件包.6,对于大多数但不是所有版本的Xcode,都有这样的软件包,并且可以用于建立带有或不带有Xcode的命令行构建环境.
  • 查看Xcode磁盘映像上的不可见包.我不记得您是否只需要DeveloperToolsCLI.pkg或其他一些信息,但是经过反复试验或使用Google搜索,您应该会到达那里.

这篇关于从Mac上的文件将G ++安装到终端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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