MacOS – Can’t compile source code on mac

gccmacosopen sourcexcode

I already have xcode installed on OSX Yosemite. I have also run it and accepted terms and conditions.

I can also do gcc --version and I see

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin14.5.0
Thread model: posix

Now if I do

wget http://apache.mirrors.pair.com//httpd/httpd-2.4.17.tar.bz2
brew install pcre
tar zxvf httpd-2.4.17.tar.bz2
cd httpd-2.4.17
./configure

The error I get is

Configure:
configure: Configuring Apache Portable Runtime Utility library...
configure:
checking for APR-util... yes
checking for gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.10.xctoolchain/usr/bin/cc
checking whether the C compiler works... no
configure: error: in `/Users/abhi/Downloads/httpd-2.4.17':
configure: error: C compiler cannot create executables
See `config.log' for more details

Why can't the C compiler create executable? I showed you that the C compiler is installed correctly on my machine.

Best Answer

You need to convince configure that there are more c compilers than gcc. Try:

export CC=clang