Reputation: 1906
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?
Upvotes: 8
Views: 11486
Reputation: 16076
I'm not sure when this changed, but Apple command line tools now include gcc and clang executables:
$ which gcc
/usr/bin/gcc
$ gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.17)
Target: x86_64-apple-darwin19.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ which clang
/usr/bin/clang
$ clang -v
Apple clang version 11.0.0 (clang-1100.0.33.17)
Target: x86_64-apple-darwin19.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
You can get it by running:
$ xcode-select --install
Upvotes: 0
Reputation: 47783
If you have Yosemite watch this video, it'll prompt you for XCode right from the command-prompt when you install Homebrew
http://dimecasts.net/Casts/CastDetails/218
Upvotes: 0
Reputation: 911
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.
Upvotes: 12