rbenv: configure: error: C compiler cannot create executables

I try to install the last stable version of ruby. But I have this error:

BUILD FAILED

Inspect or clean up the working tree at /var/folders/fn/1kz6tqdd2b58vl6lggn7ks4r0000gn/T/ruby-build.20130901135911.4559
Results logged to /var/folders/fn/1kz6tqdd2b58vl6lggn7ks4r0000gn/T/ruby-build.20130901135911.4559.log

Last 10 log lines:
checking build system type... x86_64-apple-darwin12.4.0
checking host system type... x86_64-apple-darwin12.4.0
checking target system type... x86_64-apple-darwin12.4.0
checking for gcc-4.2... gcc-4.2
checking for gcc... (cached) gcc-4.2
checking whether the C compiler works... no
configure: error: in `/var/folders/fn/1kz6tqdd2b58vl6lggn7ks4r0000gn/T/ruby-build.20130901135911.4559/ruby-2.0.0-p247':
configure: error: C compiler cannot create executables
See `config.log' for more details
make: *** No targets specified and no makefile found.  Stop.

I’m on mac OS 10.8 I opened xcode to see that the command line tool was not installed, so I installed it and I updated my rbenv and ruby-build using homebrew but there is still the error.

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Comments: 19 (2 by maintainers)

Most upvoted comments

This should be reported to the ruby-build project, where rbenv install comes from, which handles compiling Rubies. But for now:

  • What’s your rbenv install --version
  • What’s your llvm-gcc --version
  • What’s your xcode-select -print-path
  • Does this help: xcode-select -switch /Applications/Xcode.app/Contents/Developer

Hi, I managed to compile ruby 1.8.7-p375 on El Capitan (10.11.1), here’s how:

brew install apple-gcc42
brew install openssl
xcode-select --install
export CC=/usr/local/bin/gcc-4.2
export CFLAGS='-g -O2'
export RUBY_CONFIGURE_OPTS=--with-openssl-dir=`brew --prefix openssl`
export CONFIGURE_OPTS=--with-openssl-dir=`brew --prefix openssl`
rbenv install 1.8.7-p375

for Mint 19 I had to install this too sudo apt install gobjc++ and then it could compile the source code.

in my case, restart osx solved the problem.

Do you have “apple-gcc42” installed via Homebrew? It shouldn’t be necessary for building Ruby 2.0, but just checking the state of your system.

So far everything checks out. I really don’t know where your problem is. Please reopen this issue on ruby-build project and provide the info you’ve given us here.