Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Homebrew cannot find gcc

Tags:

homebrew

gcc

I'm having trouble getting homebrew to work on Lion. For some reason, it is picking up clang rather than gcc.

==> Upgrading gnutls
...
checking for gcc...
/usr/bin/clang checking whether the C compiler works... no

'brew doctor' says:

We couldn't detect gcc 4.2.x. Some formulae require this compiler. NOTE: Versions of XCode newer than 4.2 don't include gcc 4.2.x.

NOTE: I have already installed command line tools from XCode, including gcc.

$ which gcc
/usr/bin/gcc
$ gcc -v
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.9.00)

How can I force brew to use gcc?

like image 299
ishmael Avatar asked Apr 29 '12 19:04

ishmael


1 Answers

After Xcode 4.2, Apple stopped distributing gcc with Xcode. Instead, they distribute llvm-gcc (and clang), which are not gcc. You can see this with gcc -v, like you did: it shows LLVM build.

In order to use gcc, you will have to compile it yourself. There is a homebrew formula for this, but you will have to tap homebrew/dupes with brew tap homebrew/dupes.

Note that as of today, the gcc formula doesn't work if compiled with clang. You have to install it with brew install --use-llvm gcc.

Also note that Homebrew explicitly search for gcc-4.2. You will have to create a symlink for Homebrew to find gcc.

like image 62
Frizlab Avatar answered Oct 18 '22 00:10

Frizlab