Clion in Mac uses configuration gcc

Install gcc under MacOS

Homebrew

First configure and install Homebrew environment under MacOS
How to install Homebrew on Mac

Install gcc environment

View the current brew version

brew -v

Please add image description
Then use the command

brew install gcc

Please add image description
Please add image description
The final installation is complete

If you encounter "The following directories are not writable by your user:" error

Please add image description
Refer to this blog: Update and install gcc in Mac error: Error: The following directories are not writable by your user

Download speed is slow or cannot be downloaded

Change the download source
Please add image description

specific instructions

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

If this error occurs, the
Please add image description
terminal executes

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

Please add image description
Continue when done

brew install gcc

After the gcc installation is complete, we can view it using

brew list gcc

Please add image description

Clion installation configuration section


Please add image description
Open Clion, Preferences, configure the terminal input view path in Toolschains in Bulid

brew list gcc

Please add image description

C Compiler added

/usr/local/Cellar/gcc/11.2.0/bin/gcc-11

C++ Compiler add

/usr/local/Cellar/gcc/11.2.0/bin/g++-11

(Be careful not to choose the wrong order)
Please add image description
Finally, I wish you a smooth installation! ! !

Guess you like

Origin blog.csdn.net/weixin_50679163/article/details/119304282