我使用homebrew安装了最新版的gcc,但是gcc --version还是之前系统自带的gcc,版本是4.2.1
原来我新装的gcc的名字变成了gcc-7
➜ ~ gcc-7 --version
gcc-7 (Homebrew GCC 7.1.0) 7.1.0
Copyright (C) 2017 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.想使用gcc-7代替系统自带gcc的方法:
vim ~/.bash_profile
在文件中追加如下几行:
alias gcc='gcc-7'
alias g++='g++-7'
alias c++='c++-7'然后运行命令:source ~/.bash_profile
大功告成:
➜ ~ gcc-7 --version
gcc-7 (Homebrew GCC 7.1.0) 7.1.0
Copyright (C) 2017 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.
本文介绍了如何在Mac上通过homebrew安装新的gcc版本,并将其设置为默认版本,替换原有的系统自带gcc。通过编辑.bash_profile文件,添加相关路径配置,实现版本切换。
2010

被折叠的 条评论
为什么被折叠?



