Michael McGovern
Michael McGovern

Reputation: 11

gcc-11 from Homebrew Not Found by MacOS - installation and $PATH seem OK

I'm trying to compile a package called Kraken on my M1 Mac running Big Sur.

MacOS fails to compile: clang gets upset. I installed gcc from Homebrew (twice) and $ brew doctor says I'm ready to go.

My path is now:

/usr/local/opt/llvm/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/opt/homebrew/bin.

The gcc-11 etc files exist at /opt/homebrew/bin

But /usr/local/bin does not exist!

MacOS does not update the command alias for gcc:

$ rm gcc

then

$ ln -s /opt/homebrew/bin/gcc-11 gcc

return no error

but then

$ which gcc

returns

/usr/bin/gcc

I'm lost and gather this compiler-pointing has been a mess; is there any new insight here? I've seen a bunch of entries but nothing I've tried has worked.

Hoping this is a stupid newbie (me) problem, I thank you for any help you can give.

Michael

Upvotes: 1

Views: 10121

Answers (1)

Richard Barber
Richard Barber

Reputation: 6441

Homebrew avoids linking binaries with the same name as system binaries like gcc(appleclang). ln -s /opt/homebrew/bin/gcc-11 /opt/homebrew/bin/gcc or tell your configurator to explicitly use gcc-11 via CC= etc. and the same for g++-11 if C++ is used.

If it's a ./configure script, you can try calling CC=/opt/homebrew/bin/gcc-11 CXX=/opt/homebrew/bin/g++-11 ./configure

if cmake then use cmake .. -DCMAKE_C_COMPILER=/opt/homebrew/bin/gcc-11 -DCMAKE_CXX_COMPILER=/opt/homebrew/gcc++-11

Also, try seeing where the homebrew gcc link points ls -l /opt/homebrew/bin/gcc

Upvotes: 1

Related Questions