macos - 带有 Homebrew 的 Mac OS X : Installed and linked gcc 6. 2,但 gcc --version 仍然显示 4.9.2

标签 macos gcc homebrew

在 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/

相关文章:

c++ - c++ 中的 gcc 浮点指针转换导致 SIGBUS 错误

macos - Postgresql 安装 : command not found: createdb, psql

python - 在 Mac OS X Yosemite 上安装 Python3

bash - 如何确保 Mongo 二进制文件在我的 PATH 中 - 在 Mac 上的 shell rc (~/.bashrc) 中

python - 对 JPG 图像进行操作时获取 "cannot write mode P as JPEG"

php - 如何在 Mac OS X 10.5 Leopard 上设置 PEAR

mysql - OSX Docker/WordPress/MySQL -- 连接错误 : (1130) Host 'xxx.xxx.xxx.xxx' is not allowed to connect to this MariaDB server

C - 调用松散定义的函数时生成警告

c - 在 gcc ver 4.6.3 中按值将 Struct 作为参数传递给函数时出错

macos - 我怎样才能从Applescript调用brew