我尝试使用这个教程下载最新版的 g++,并将版本号从 4.7 更改为最新的版本(我相信是)8.1。但我遇到了以下错误。
Error: No available formula with the name "gcc81"
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get complete history run:
git -C "$(brew --repo homebrew/core)" fetch --unshallow
Error: No previously deleted formula found.
==> Searching for similarly named formulae...
==> Searching local taps...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
Error: No formulae found in taps.
有人知道如何更新我的g++版本吗?这是我尝试查找当前版本时得到的信息。
g++ --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.1.0 (clang-902.0.39.1)
Target: x86_64-apple-darwin17.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
抱歉我太菜了,在这里真的很努力学习。
g++
时得到的实际上是苹果安装的clang++
编译器。这是苹果做的一个奇怪的事情,将g++
别名。所以你不需要“升级”而是“安装”。无论如何,如果你尝试brew install gcc
,没有指定版本,会发生什么? - juanchopanzabrew install gcc
。您可以使用brew search gcc
查找选项,使用brew info gcc
确定gcc包中提供的版本。为了防止Homebrew安装的gcc与Mac自带的gcc发生冲突,Homebrew在所有文件名后面加上“-8”的后缀,因此通过gcc-8
调用gcc
,通过g++-8
调用g++
。因此,如果您正在使用makefile,则应设置环境变量CC=gcc-8 CXX=g++-8
。这些变量应该会传递到makefile或配置脚本中。 - Anya Shenanigans