Mac OS X:安装并链接gcc 6.2与Homebrew,但gcc --version仍然说4.9.2 [英] Mac OS X: Installed and linked gcc 6.2 with Homebrew, but gcc --version still says 4.9.2
问题描述
在OS X 10.11.6上,我使用自制软件安装了gcc 6.2.0。它住在usr / local / Cellar / gcc / 6.2.0 / bin中。在获得链接后(它不会自动执行此操作),我在那里尝试从这个其他线程创建一个别名
ln -s gcc-6 gcc
然后gcc --version给我
cc(GCC)4.9.2 20141029(预发行版)
版权所有(C)2014 Free Software Foundation, Inc.
这是免费软件;请参阅复制条件的来源。没有任何b $ b保修;甚至不适用于适销性或针对特定用途的适用性。
所有这些都是因为尝试安装事件会因为-rdynamic标志而崩溃,我希望在一个更新的版本中修复。
gcc
),但忘了将 PATH
设置到新安装的位置(或将其设置在系统路径后面)。 令人困惑的是您的系统已经安装了一个gcc版本。您必须重写默认路径,以便您的 gcc
命令优先。
〜/ .profile
文件并检查PATH调整。最后添加一行:
$ b
export PATH = / usr / local / Cellar / gcc / 6.2.0 / bin:$ PATH
然后打开一个新终端并确保哪个gcc
打印
/usr/local/Cellar/gcc/6.2.0/bin/gcc
On OS X 10.11.6, I installed gcc 6.2.0 using homebrew. It lives over in usr/local/Cellar/gcc/6.2.0/bin. After getting it to link (it didn't do this automagically), I cd there and try the solution from this other thread to create an alias
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.
All this is because trying to install things crashes because of -rdynamic flags, that I hope is fixed in a newer version.
You created the symlink with the proper target name (gcc
) but forgot to set the PATH
to your newly installed location (or set it after the system path).
What's confusing is that your system already has a version of gcc installed. You have to override the default path so your gcc
command comes first.
edit your
~/.profile
file and check PATH adjustment. Add a line in the end which contains:export PATH=/usr/local/Cellar/gcc/6.2.0/bin:$PATH
Then open a new terminal and ensure that which gcc
prints
/usr/local/Cellar/gcc/6.2.0/bin/gcc
这篇关于Mac OS X:安装并链接gcc 6.2与Homebrew,但gcc --version仍然说4.9.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!