GCC 在brew更新后停止工作



我不知道这是否是正确的地方,所以如果我做错了什么,请告诉我。

我正在学习 c 编程,我正在尝试设置 git,因为我也想学习它。我遵循了一些说明,git 似乎工作正常,但现在每当我键入一些 gcc 命令时我都会收到错误。

我是整个终端的新手,并尝试了一些我在stackoverflow上找到的命令,但这并没有解决我的问题。

尝试编译 C 程序后,我收到以下消息:

dyld: Library not loaded: /usr/local/lib/libmpfr.4.dylib Referenced 
from: /usr/local/libexec/gcc/x86_64-apple-darwin15.0.0/6.1.0/cc1 
Reason: image not found
gcc: internal compiler error: Abort trap: 6 (program cc1)

运行"brew doctor"后,我还得到以下输出:

Warning: You have unlinked kegs in your Cellar Leaving kegs unlinked 
can lead to build-trouble and cause brews that depend on those kegs to 
fail to run properly once built. Run brew link on these: gawk
Warning: Homebrew's sbin was not found in your PATH but you have 
installed formulae that put executables in /usr/local/sbin. Consider 
setting the PATH for example like so echo 'export 
PATH="/usr/local/sbin:$PATH"' >> ~/.bash_profile

gcc 也是我与"brew link gcc"链接的未链接桶的一部分,起初它给出了一些错误消息,但在从 SE 运行命令后,这起作用了。

如果我运行"gcc --version",我会得到通常的输出(gcc 版本 6.1.0)。

任何帮助将不胜感激,因为我渴望继续编程,这有点破坏了我平静的编码:(

谢谢。

编辑:恢复备份后,$brew更新$brew升级:

==> Pouring gcc-7.3.0_1.high_sierra.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/gfortran
Target /usr/local/bin/gfortran
already exists. You may want to remove it:
rm '/usr/local/bin/gfortran'
To force the link and overwrite all conflicting files:
brew link --overwrite gcc
To list all files that would be deleted:
brew link --overwrite --dry-run gcc
Possible conflicting files are:
/usr/local/bin/gfortran

首先,您以前是否从Homebrew以外的来源安装了gcc?其次,您的自制存储库是最新的(brew update)吗?

如果您在安装了命令行工具的Mac上,则完全按照编写的方式运行gcc --version应该返回Xcode随附的Apple gcc版本,即4.2.1。为了防止冲突,Homebrew将其gcc链接到gcc-x,其中x是当前的主要版本。这就是为什么我想知道您的自制存储库是否过时,因为当前的自制 gcc 版本是 7(例如,gcc-7 --version)。

如果您以前安装了非自制 gcc,则可以使用指向该安装的符号链接,该安装可能会返回 gcc 版本 6.1.0。如果是这种情况,最好的办法是使用适当的卸载方法删除非自制的gcc版本6.1.0,无论您从哪里获得它。现在/usr/local/bin 中应该没有冲突的 gfortran 符号链接,从更新的存储库重新安装自制 gcc 应该不会出错。

如果您从未安装过非自制的gcc,那么按照错误说明指示删除旧符号链接应该是安全的。这是因为/usr/local 目录是为用户保留的,除非您通过自制软件或其他一些用户安装(上面已解决)将它们放在那里,否则不会有任何 gfortran 符号链接。

您可能还需要检查可能解决某些问题的brew prune -h

最新更新