Mac OS X: Installed and linked gcc 6.2 with Homebrew, but gcc --version still says 4.9.2

耗尽温柔 提交于 2019-12-05 02:18:55

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/39518634/mac-os-x-installed-and-linked-gcc-6-2-with-homebrew-but-gcc-version-still-sa

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!