How to specify what is used as the real C compiler

gccxcode

I have a configure on Mountain Lion that's running into trouble:

[snip]
checking for gcc...
/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc
checking whether the C compiler works... no
configure: error: in `/Users/jonathan/Downloads/httpd-2.4.4':
configure: error: C compiler cannot create executables
See `config.log' for more details

Meanwhile, I have just opened Xcode and installed command-like tools, including /usr/bin/gcc.

Is there a way I can invoke the configure script so it will take /usr/bin/gcc as the C compiler?

And when I specified:

CC=/usr/bin/gcc

It gives:

checking how to run the C preprocessor... /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc -E
configure: error: in `/Users/jonathan/Downloads/httpd-2.4.4':
configure: error: C preprocessor "/Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc -E" fails sanity check
See `config.log' for more details

For now I'll ask: how do I tell it what to use as the C preprocessor?

(Long-term what I'd like is to know why it's not aware of standard command line tools and pulls C-related functionality from an esoteric place.

Best Answer

Apple's gcc binary is really llvm.

Mac:~ bmike$ which gcc
/usr/bin/gcc
Mac:~ bmike$ gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

You'll want to obtain gcc from homebrew or from source if you need gcc and not llvm standing in for gcc.

Good reading abounds on various blogs:

Once you've gotten a real version of gcc installed, you can export CC=/usr/local/bin/gcc or whatever else you prefer for setting the environment variable to match were you choose to store your now non-llvm-based compiler.