【发布时间】:2018-11-03 05:04:47
【问题描述】:
我尝试使用this 教程下载最新版本的 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
对不起,我是个菜鸟,我真的很想在这里学习。
【问题讨论】:
-
我对自制软件了解不多,但您似乎没有安装任何 gcc。运行
g++时得到的实际上是苹果安装的clang++编译器。苹果做的事情很奇怪,别名g++。所以你不需要像“安装”那样“升级”。无论如何,如果你尝试brew install gcc,没有版本会发生什么? -
我认为这些天你在 OSX 上尝试使用 gcc 可能会违背规律——Apple 正在努力让人们转向 clang。为什么需要它?
-
Homebrew gcc 8 由
brew install gcc安装。您可以brew search gcc查找选项,brew info gcc确定 gcc 包中提供的版本。为了防止 homebrew 安装的 gcc 与 mac 冲突,homebrew 在所有文件上都加上了-8的后缀,所以gcc被gcc-8调用,g++被g++-8调用。所以如果你使用makefile,你需要设置环境变量CC=gcc-8 CXX=g++-8,这些应该带入makefile,或者配置脚本。