MAC上安装GCC失败

问题

在用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

参考

posted @ 2019-02-14 11:35  辵鵵  阅读(8452)  评论(0编辑  收藏  举报