https://codeforces.com/blog/entry/106465?locale=ru
- Go to brew official website and copy the code below “Install Homebrew”, it will be like
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Open Terminal from the launchpad and paste it in your terminal and press enter to run it.
- Now it will ask for the sudo password and then enter your mac password and then run it. Next it will ask press RETURN to continue and hit return. After then it will take take some time to download and install it on your mac.
- After some time, it will show: View this image. Then copy the first code and then run it and then copy the second code and then run it. If it doesn’t run reopen the terminal and then run it. It will show something like this.
- Now reopen the terminal and type
brew
and press enter. It should show the list of all the brew commands - Congratulations now you have successfully installed brew on your mac.
- Now its time to install GCC compiler in your MAC.
- Open terminal and type
brew install gcc
- Now type
g++-12 --version
and it will show the current version of the gcc compiler installed. - Now type
g++ --version
it will show apple clang instead of gcc. Something like this. - That means the current default compiler is clang not gcc. So we have to set it to GCC compiler as the default compiler.
- Now type
cd /opt/homebrew/bin
, press enter and then typeln -s g++-12 g++
and press enter. - Now again type
g++ --version
and it will show something like this. That means you have successfully installed gcc in your MAC and has been set as the default compiler.
Похожие статьи