我有一台 MacBook Pro,想在上面进行一些开发。
我有一个程序需要构建,在使用 make
构建时出现了“命令未找到”的错误。我做了一些谷歌和 Stack Overflow 搜索,似乎这不是常见的问题。为什么我没有安装 make
以及如何获得它?
我感到特别困惑,因为我知道最近(大约在过去的一个月)在这台笔记本电脑上用过它。
对于使用 Xcode 4.3 和 Lion 的用户,命令行工具不再默认捆绑,并且没有 /Developer 目录。要安装它们,请打开 Xcode,转到偏好设置 -> 下载 -> 组件 -> 命令行工具。这将安装 make、gcc 等工具。
现在通过osx-gcc-installer,在OS X上安装gcc工具链的另一种方法已经出现,其中包括:
这个下载仅有282MB,而Xcode需要3GB。
另外,如果您将用户文件和应用程序从一台 Mac 迁移到另一台 Mac,则需要重新安装 Apple Developer 工具。迁移助理不会考虑开发人员工具的安装。
@Daniel的建议完美地解决了我的问题。要安装make
,打开Xcode,在“偏好设置”->“下载”->“组件”->“命令行工具”中进行安装。然后您可以使用gcc -v
进行测试。
export PATH=$PATH:/Applications/Xcode.app/Contents/Developer/usr/bin
我发现开发者工具不像其他工具那样容易获取。在El Capitan中,我只需在终端中使用gcc -v命令,它会提示gcc不可用并询问我是否要安装命令行Apple开发者工具。无需下载Xcode。以下是终端会话:
Pauls-MBP:~ paulhillman$ gcc -v
xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. Choose an option in the dialog to download the command line developer tools.
Pauls-MBP:~ paulhillman$ gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin