macos 在 OS X 上使用“make”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1469994/
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
Using 'make' on OS X
提问by Alex
I have a MacBook Pro that I'm trying to do some development on.
我有一台 MacBook Pro,我正在尝试对其进行一些开发。
I have a program I want to build, and when I went to use make
to build it, I got a "command not found" error. I did some googling and Stack Overflow searches and it doesn't look like this is a common problem. Why don't I have make
installed and how do I get it?
我有一个要构建的程序,当我去make
构建它时,出现“找不到命令”错误。我做了一些谷歌搜索和 Stack Overflow 搜索,看起来这不是一个常见问题。为什么我没有make
安装,如何获得?
I'm extra confused, because I know I used it relatively recently (in the past month or so) when I was on this laptop.
我特别困惑,因为我知道我最近(在过去一个月左右)使用这台笔记本电脑时使用过它。
采纳答案by Friedrich
Have you installed the Apple developer tools? What happens if you type gcc -v ?
您是否安装了 Apple 开发人员工具?如果你输入 gcc -v 会发生什么?
It look as if you do not have downloaded the development stuff. You can get it for free (after registration) from http://developer.apple.com/
看起来好像你还没有下载开发的东西。您可以从http://developer.apple.com/免费(注册后)获得它
回答by Daniel
For those of you who get to this page using Xcode 4.3 and Lion, the command line tools are no longer bundled by default, and there is no /Developer anymore. To install them, open Xcode, go to Preferences -> Downloads -> Components -> Command Line Tools. This should install make, gcc etc.
对于那些使用 Xcode 4.3 和 Lion 访问此页面的人,默认情况下不再捆绑命令行工具,也不再有 /Developer。要安装它们,请打开 Xcode,转到首选项 -> 下载 -> 组件 -> 命令行工具。这应该安装 make、gcc 等。
回答by Ben
There is now another way to install the gcc toolchain on OS X through the osx-gcc-installerthis includes:
现在有另一种方法可以通过osx-gcc-installer在 OS X 上安装 gcc 工具链,其中包括:
- GCC
- LLVM
- Clang
- Developer CLI Tools (purge, make, etc)
- DevSDK (headers, etc)
- 海湾合作委员会
- 虚拟机
- 铛
- 开发人员 CLI 工具(清除、制作等)
- DevSDK(头文件等)
The download is 282MB vs 3GB for Xcode.
下载为 282MB,而 Xcode 为 3GB。
回答by ayaz
You will have to install the "Developer Tools" that are provided as optional packages in OS X installation disks.
您必须安装 OS X 安装盘中作为可选包提供的“开发者工具”。
回答by Jay Baxter
For Xcode 4.1 you can simply add /Developer/usr/binto the PATH environment variable. This is easily done:
对于 Xcode 4.1,您可以简单地将/Developer/usr/bin 添加到 PATH 环境变量中。这很容易做到:
$ export PATH=$PATH:/Developer/usr/bin
$ export PATH=$PATH:/Developer/usr/bin
Also be certain to update your ~/.bashrc (or ~/.profile or ~/.bash_login) file.
还要确保更新您的 ~/.bashrc(或 ~/.profile 或 ~/.bash_login)文件。
回答by Nicolaj Schweitz
In addition, if you have migrated your user files and applications from one mac to another, you need to install Apple Developer Tools all over again. The migration assistant does not account for the developer tools installation.
此外,如果您已将用户文件和应用程序从一台 Mac 迁移到另一台 Mac,则需要重新安装 Apple Developer Tools。迁移助手不考虑开发者工具的安装。
回答by Eric
If you've installed Xcode 4.3 and its Command Line Tools, just open Terminal and type the following: On Xcode 4.3, type the following in Terminal:
如果您已经安装了 Xcode 4.3 及其命令行工具,只需打开终端并键入以下内容: 在 Xcode 4.3 中,在终端中键入以下内容:
export PATH=$PATH:/Applications/Xcode.app/Contents/Developer/usr/bin
export PATH=$PATH:/Applications/Xcode.app/Contents/Developer/usr/bin
回答by Pea
@Daniel's suggestion worked perfectly for me. To install
@Daniel 的建议非常适合我。安装
make, 打开 Xcode, 转到 Preferences -> Downloads -> Components -> Command Line Tools. You can then test with
gcc -v
回答by Harold L
回答by Alex Kessaris
I believe you can also get just the Xcode command-line tools which is about 170 MB.. It's described in the 'brew' setup guide: https://github.com/mxcl/homebrew/wiki/installationand can be found here: https://developer.apple.com/downloads/index.action#
我相信您也可以获得大约 170 MB 的 Xcode 命令行工具。它在“brew”设置指南中进行了描述:https: //github.com/mxcl/homebrew/wiki/installation,可以在这里找到:https: //developer.apple.com/downloads/index.action#
Edit: this was already mentioned above by @josh
编辑:@josh 上面已经提到了这一点