Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

configure: error: C compiler cannot create executables

I have 10.8 installed and Xcode 4.4 with Command Line tools, and yet I was still getting this error. Rather than reinstall Xcode, I noticed there were two relevant lines in my config.log:

configure:5130: checking for C compiler version
configure:5139: /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain/usr/bin/cc --version >&5

That path did not exist for me. Instead I had:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain

The C compiler ("cc") is located inside of that xctoolchain directory. I created a symlink for OSX10.8.xctoolchain to point to XcodeDefault.xctoolchain and that fixed it. Now the memcached installation script can find the compiler version and continue on its way.

cd /Applications/Xcode.app/Contents/Developer/Toolchains
sudo ln -s XcodeDefault.xctoolchain OSX10.8.xctoolchain

As suggested in the comments, if you are having this problem on Yosemite (10.10) or Mavericks (10.9), you can update the symlink command above to point to that specific version (OSX10.9.xctoolchain or OSX10.10.xctoolchain).


You have an old set of developer tools. gcc is reporting its version as 4.0.1. This may be left over from migrating from an older version of the OS. If you've installed Xcode 4.3.x, you need to launch it, go into its preferences, select the Locations tab, and click "Install" next to the Command Line Tools package.


When you see this error message, you might not have accepted the Xcode license agreement yet after an upgrade.

First of all, make sure you have upgraded your commandline tools:

$ xcode-select --install

Now Apple wants you to agree to their license before you can use these tools:

$ gcc
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.

$ sudo gcc
You have not agreed to the Xcode license agreements. You must agree to both license agreements below in order to use Xcode.
[...]

After you have accepted it, the commandline tools will work as expected.


I had already installed the command line tools in xcode but I mine still errored out on:

line 3619: /usr/bin/gcc-4.2: No such file or directory

When I entered which gcc it returned

/usr/bin/gcc

When I entered gcc -v I got a bunch of stuff then

..  
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)

So I created a symlink:

cd /usr/bin
sudo ln -s gcc gcc-4.2

And it worked!

(the config.log file is located in the directory that make is trying to build something in)


I just had this issue building apache. The solution I used was the same as Mostafa, I had to export 2 variables:

export CC=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
CPP='/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -E'

This was one Mac OSX Mavericks


First get the gcc path using

Command: which gcc

Output: /usr/bin/gcc

I had the same issue, Please set the gcc path in below command and install

CC=/usr/bin/gcc rvm install 1.9.3

Later if you get "Ruby was built without documentation" run below command

rvm docs generate-ri