Reputation: 29
How do I install the latest version of GCC on my macOS Big Sur. I am using Visual Studio Code, version 1.60 and I want to run C++ programs using it. I tried using homebrew to install GCC but it kept on giving me errors.
E.g.: When I typed in the path as /opt/homebrew/Cellar/gcc/11.2.0/bin
Result: zsh: permission denied: /opt/homebrew/Cellar/gcc/11.2.0/bin
What is wrong with the permission? How will I make it allow.
Upvotes: 1
Views: 4276
Reputation: 208107
Firstly, /opt/homebrew/Cellar/gcc/11.2.0/bin
is a directory, so you can't run that.
Secondly, homebrew generally makes symbolic links in /usr/local/bin
for everything it installs, so you should add that to your PATH, e.g.
export PATH=/usr/local/bin:$PATH
Then you need to look in /usr/local/bin
to see what program name you need, e.g.
ls /usr/local/bin/gcc*
and if you see gcc-11
in there, you then need to compile with:
gcc-11 program.c
Note you will need to look for g++*
if you actually mean C++ rather than C.
Upvotes: 1