在 OS X 10.11.6 上,我使用 Homebrew 软件安装了 gcc 6.2.0。它存在于 usr/local/Cellar/gcc/6.2.0/bin 中。让它链接后(它没有自动执行此操作),我 cd 到那里并尝试来自 this other thread 的解决方案创建别名
ln -s gcc-6 gcc then gcc --version gives me cc (GCC) 4.9.2 20141029 (prerelease) Copyright (C) 2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
所有这些都是因为 -rdynamic 标志导致尝试安装时崩溃,我希望在较新的版本中得到修复。
最佳答案
您使用正确的目标名称 (gcc
) 创建了符号链接(symbolic link),但忘记将 PATH
设置为新安装的位置(或将其设置在系统路径之后)。
令人困惑的是你的系统已经安装了一个版本的 gcc。您必须覆盖默认路径,以便您的 gcc
命令排在第一位。
编辑您的
~/.profile
文件并检查 PATH 调整。在末尾添加一行,其中包含:export PATH=/usr/local/Cellar/gcc/6.2.0/bin:$PATH
然后打开一个新终端并确保which gcc
打印
/usr/local/Cellar/gcc/6.2.0/bin/gcc
关于macos - 带有 Homebrew 的 Mac OS X : Installed and linked gcc 6. 2,但 gcc --version 仍然显示 4.9.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39518634/