command line tools for OS X的安装

本文提供了一步一步的操作指南,详细说明如何在Mac OS系统中通过终端命令行安装和配置Command Line Tools,包括安装Xcode、解决路径问题及使用sudo命令的注意事项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、打开终端,输入“xcode-select --install”;

2、在弹出的对话框中,未安装Xcode则点击对应图标进行Xcode的安装 若已安装,则点击对话框中的“安装”按钮进行command line tools的安装。

3、安装完毕,在终端命令行输入“gcc -v”进行安装验证测试。之后可能会跳出以下语句:

xcrun: error: active developer path ("/Users/fighter/Desktop/Xcode.app/Contents/Developer") does not exist, use `xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools (or see `man xcode-select`)


以上大致意思是在当前的路径下找不到Xcode软件,要求修改Xcode的路径。具体办法:

xcode-select --switch +xcode.app的当前路径(依次打开Finder >>应用程序,用鼠标左键选中其中的Xcode.app图标拖到终端"xcode-select --switch "命令后即可。注意有空格)

4、按回车后终端跳出以下提示:

WARNING: Improper use of the sudo command could lead to data loss

or the deletion of important system files. Please double-check your

typing when using sudo. Type "man sudo" for more information.

To proceed, enter your password, or type Ctrl-C to abort.

Password:


我们在password处输入计算的管理密码(即登录密码),然后按回车确认;

5、

这时,我们可以在终端中输入gcc -v进行安装测试。出现提示语句:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1

Apple LLVM version 7.0.0 (clang-700.0.72)

Target: x86_64-apple-darwin14.0.0

Thread model: posix


至此,我们的command line tools就安装成功了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值