简体   繁体   English

酿造更新后GCC停止工作

[英]GCC stopped working after brew update

I don't know if this is the right place to ask so let me know if I'm doing anything wrong. 我不知道这是问的地方,所以让我知道我做错了什么。

I'm learning c programming, and I was trying to setup git since I want to learn that too. 我正在学习c编程,并且由于我也想学习git而试图安装git。 I followed some instructions and git seems to be working fine, but now I get an error whenever I type some gcc command. 我遵循了一些说明,并且git似乎运行良好,但是现在每当键入一些gcc命令时,我都会收到一条错误消息。

I'm new to the whole terminal thing and tried some commands I found on stackoverflow but that didn't resolve my issue. 我是整个终端的新手,并尝试了一些在stackoverflow上发现的命令,但这不能解决我的问题。

I get the following message after trying to compile a C programm: 尝试编译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)

I also get the following output after running 'brew doctor': 运行“ 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 was also part of the unlinked kegs which I linked with 'brew link gcc', which at first gave some error message but after running a command from SE this worked. gcc也是我与“ brew link gcc”链接的未链接小桶的一部分,该链接最初提供了一些错误消息,但是在从SE运行命令后可以正常工作。

If I run 'gcc --version' I get the usual output (gcc version 6.1.0). 如果我运行'gcc --version',则会得到通常的输出(gcc版本6.1.0)。

Any help would be appreciated since I'm eager to continue programming and this is kinda destroying my evening of calm coding :( 任何帮助将不胜感激,因为我渴望继续编程,这有点破坏了我平静的编码之夜:(

Thanks. 谢谢。

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

First, have you previously installed gcc from a source other than Homebrew? 首先,您以前是否从Homebrew以外的来源安装了gcc? Second, is your homebrew repo up to date ( brew update )? 其次,您的自制软件回购是最新的吗( brew update )?

If you are on Mac with Command Line Tools installed, running gcc --version exactly as written should return the Apple gcc version supplied with Xcode which is 4.2.1. 如果您在Mac上安装了命令行工具,则完全按照书面说明运行gcc --version应该返回Xcode附带的Apple gcc版本4.2.1。 To prevent conflicts, homebrew links its gcc to gcc-x where x is the current major release. 为了防止冲突,自制软件会将其gcc链接到gcc-x,其中x是当前的主要版本。 This is why I wonder if your homebrew repo is out of date since the current homebrew gcc version is 7 (eg, gcc-7 --version ). 这就是为什么我不知道您的自制软件回购是否过时的原因,因为当前的自制软件gcc版本是7(例如gcc-7 --version )。

If you have previously installed a non-homebrew gcc, you could have symlinks pointing to that installation which may return gcc version 6.1.0. 如果以前安装了非自制gcc,则可能会有指向该安装的符号链接,这些链接可能会返回gcc 6.1.0版本。 If this is the case, your best bet is to remove the non-homebrew gcc version 6.1.0 using the appropriate uninstall methods available from wherever you got it. 在这种情况下,最好的选择是从任何地方使用可用的适当卸载方法删除非自制gcc版本6.1.0。 Now there should be no conflicting gfortran symlinks in /usr/local/bin and reinstalling homebrew gcc from an updated repository should proceed without errors. 现在,/ usr / local / bin中应该没有冲突的gfortran符号链接,并且应该从更新的存储库重新安装homebrew gcc,应该继续进行而不会出现错误。

If you've never installed a non-homebrew gcc then it should be safe to do as the error instructions indicate with respect to removing the old symlink. 如果您从未安装过非自制的gcc,则应安全进行,因为错误说明指出了删除旧的符号链接。 This is because /usr/local directory is reserved for the User and would not have any gfortran symlinks unless you put them there via homebrew or some other user installation (which was addressed above). 这是因为/ usr / local目录是为用户保留的,并且没有任何gfortran符号链接,除非您通过自制程序或其他一些用户安装(上面已解决)将它们放置在那里。

You also may want to examine brew prune -h which might address some of your issues as well. 您可能还需要检查brew prune -h ,它也可以解决您的一些问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM