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
Then use the command
brew install gcc
The final installation is complete
If you encounter "The following directories are not writable by your user:" error
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
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
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
Continue when done
brew install gcc
After the gcc installation is complete, we can view it using
brew list gcc
Clion installation configuration section
Open Clion, Preferences, configure the terminal input view path in Toolschains in Bulid
brew list gcc
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)
Finally, I wish you a smooth installation! ! !