macbook中gcc被定义为clang,而正统的gnu gcc却只能使用gcc-7(gcc 7版本),然而,如果修改/usr/bin的链接,还容易造成系统错误,因为mac的工具链和gcc(clang版)高度集成,搜索了一下,发现有高手通过巧用alias来完美的解决了这个问题,而且还可以在需要时,随时undo。
在用户目录下,修改.bash_profile文件 alias gcc="gcc-7" alias cc="gcc-7" alias g++="g++-7" alias c++="c++-7"
原文如下:https://apple.stackexchange.com/questions/99077/how-to-set-gcc-4-8-as-default-gcc-compiler
Thanks to you all for your help. I ended up just creating aliases within ~/.bash_profile
as follows:
alias gcc=‘gcc-4.8‘
alias cc=‘gcc-4.8‘
alias g++=‘g++-4.8‘
alias c++=‘c++-4.8‘
This is basically what Lyken suggested but easier to undo if necessary.
参考文章:http://blog.csdn.net/u010167269/article/details/51951582