Aditi Singh
Aditi Singh

Reputation: 29

How to install gcc 11.2.0 on macOS Big Sur with the Apple M1 processor

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

Answers (1)

Mark Setchell
Mark Setchell

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

Related Questions