我使用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.
版权声明:本文为qoopqpqp原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。