Macos 在brew更新后,GCC停止工作

Macos 在brew更新后,GCC停止工作,macos,gcc,homebrew,Macos,Gcc,Homebrew,我不知道这是不是该问的地方,所以如果我做错了什么,请告诉我 我正在学习c编程,我试图设置git,因为我也想学习它。我遵循了一些说明,git似乎工作得很好,但现在每当我键入一些gcc命令时都会出现错误 我不熟悉整个终端,并尝试了在stackoverflow上找到的一些命令,但这并没有解决我的问题 在尝试编译C程序后,我收到以下消息: dyld: Library not loaded: /usr/local/lib/libmpfr.4.dylib Referenced from: /usr/loc

我不知道这是不是该问的地方,所以如果我做错了什么,请告诉我

我正在学习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医生”后,我还获得以下输出:

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链接gcc”链接,它最初给出了一些错误消息,但在运行SE的命令后,这一点起了作用

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

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

谢谢

编辑:恢复备份后,$brew update$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

首先,您以前是否从非自制的来源安装过gcc?其次,您的自制repo是否是最新的(
brew update

如果您在Mac电脑上安装了命令行工具,那么完全按照编写的方式运行
gcc--version
应该会返回随Xcode提供的Apple gcc版本,即4.2.1。为了防止冲突,homebrew将其gcc链接到gcc-x,其中x是当前的主要版本。这就是为什么我想知道您的homebrew repo是否在当前版本之后过期的原因自制gcc版本为7(例如,
gcc-7--version

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

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


您可能还想检查一下
brew prune-h
,它可能也会解决您的一些问题。

当您将
sbin
放回
路径时会发生什么?嘿,Srini,谢谢,正如我说的,我是新手,所以我导出了PATH=$PATH:/usr/local/sbin,然后brew重新安装gcc,但我仍然收到了相同的消息。Homebrew仍然抱怨添加后sbin不在路径上?不,问题已解决,谢谢!但gcc仍然不工作我是否在尝试更新gcc时rm'/usr/local/bin/gfortran'导致错误?