Mac中Clion使用配置gcc

在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

(注意不要选错顺序)
请添加图片描述
最后祝你安装顺利!!!

猜你喜欢

转载自blog.csdn.net/weixin_50679163/article/details/119304282
今日推荐