MAC上安装GCC失败

在MAC上使用brew安装GCC时遇到错误,由于Xcode的Command Line Tools未安装。解决方法是首先更新Xcode,然后参照教程安装Command Line Tools。

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

o_PoweredByMacOSXLarge.gif

问题

在用brew安装GCC时, 报了如下错误.

➜  ~ brew install gcc
==> Installing dependencies for gcc: isl, mpfr and libmpc
==> Installing gcc dependency: isl
==> Downloading https://homebrew.bintray.com/bottles/isl-0.20.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring isl-0.20.mojave.bottle.tar.gz
?  /usr/local/Cellar/isl/0.20: 71 files, 3.9MB
==> Installing gcc dependency: mpfr
==> Downloading https://homebrew.bintray.com/bottles/mpfr-4.0.1.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring mpfr-4.0.1.mojave.bottle.tar.gz
?  /usr/local/Cellar/mpfr/4.0.1: 28 files, 4.6MB
==> Installing gcc dependency: libmpc
==> Downloading https://homebrew.bintray.com/bottles/libmpc-1.1.0.mojave.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libmpc-1.1.0.mojave.bottle.tar.gz
?  /usr/local/Cellar/libmpc/1.1.0: 12 files, 354KB
==> Installing gcc
Warning: Building gcc from source:
  The bottle needs the Xcode CLT to be installed.
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Error: An exception occurred within a child process:
  CompilerSelectionError: gcc cannot be built with any available compilers.
Install GNU's GCC
  brew install gcc

原因是 在从App Store上下载Xcode后,默认是不会安装Command Line Tools的.

解决方法

这时需要先更新一下xcode

xcode-select --install

参考

转载于:https://www.cnblogs.com/qyf404/p/how_install_gcc_in_mac.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值