在MacOS下安装gcc
Homebrew
先在MacOS下配置安装Homebrew环境 如何在Mac里安装Homebrew
安装gcc环境
查看当前brew版本
brew -v
 接着使用指令
brew install gcc
  最后安装完成
如果遇到“The following directories are not writable by your user:”错误
 参考这篇博客:Mac中更新安装gcc报错:Error: The following directories are not writable by your user
下载速度慢或者无法下载
更换下载源 
具体一下指令
cd "$(brew --repo)"
git remote set-url origin https://github.com/Homebrew/brew.git
cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
git remote set-url origin https://github.com/Homebrew/homebrew-core.git
brew install gcc
若出现这种报错  终端执行
cd "$(brew --repo)/Library/Taps/"
rm -rf homebrew
mkdir homebrew
cd homebrew
git clone git://mirrors.ustc.edu.cn/homebrew-core.git
git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
 完成后继续
brew install gcc
在gcc安装完成后,我们可以使用进行查看
brew list gcc

Clion安装配置部分
打开Clion,首选项,Bulid里Toolschains里配置  终端输入查看路径
brew list gcc

C Compiler 添加
/usr/local/Cellar/gcc/11.2.0/bin/gcc-11
C++ Compiler添加
/usr/local/Cellar/gcc/11.2.0/bin/g++-11
(注意不要选错顺序)  最后祝你安装顺利!!!
|