1

I am trying to install and work with gcc compiler on my MacBook M1. I have installed gcc using home-brew, but I did not find a way to use it on the terminal in my Mac. I wanted to download a tool that uses gcc compiler for its installation. Specifically, it looks like the tool needs OpenMP and clang does not support it.

Error message when I run make command:

clang: error: unsupported option '-fopenmp'

When I change the path to the gcc installation path, I am unable to run basic commands like ls in the terminal. I understand that this is the reason for that. Could anyone please help?

sindhuja
  • 167
  • 1
  • 12

1 Answers1

0

My (now rather old) discussion of this is on my CpuFun blog: Setting up the Apple M1 for Native Code Development from the Command Line

The short version is

  1. Be very careful about running X86_64 compiled shells. (You don't want to!)
  2. Use brew to install the relevant native compilers, but make sure that you have added the correct (/opt/homebrew/...) path to your PATH envirable. (See the Homebrew 3.0.0 release notes.)

Without more information about how you changed your PATH it's impossible to say what is wrong in your case, but it does sound as if you simply assigned a single directory to the PATH, rather than adding to it...

Remember that there are a number of useful commands to help you diagnose problems like this:-

  • which command
    to tell you where command is coming from.

  • The --version flag to the compilers to show which compiler they are.

  • brew may not make a link for the name gcc alone, but rather install gcc-11 (or whatever), so you you may need to do that explicitly.

Jim Cownie
  • 2,409
  • 1
  • 11
  • 20