New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

configure: error: C compiler cannot create executables #440

Closed
tellijo opened this Issue Sep 1, 2013 · 18 comments

Comments

Projects
None yet
@tellijo

tellijo commented Sep 1, 2013

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.

@mislav

This comment has been minimized.

Show comment
Hide comment
@mislav

mislav Sep 1, 2013

Member

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
Member

mislav commented Sep 1, 2013

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
@tellijo

This comment has been minimized.

Show comment
Hide comment
@tellijo

tellijo Sep 1, 2013

rbenv install --version: ruby-build 20130806
llvm-gcc --version: i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
xcode-select -print-path: /Applications/Xcode.app/Contents/Developer

tellijo commented Sep 1, 2013

rbenv install --version: ruby-build 20130806
llvm-gcc --version: i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
xcode-select -print-path: /Applications/Xcode.app/Contents/Developer

@mislav

This comment has been minimized.

Show comment
Hide comment
@mislav

mislav Sep 1, 2013

Member

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.

Member

mislav commented Sep 1, 2013

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.

@mislav mislav closed this Sep 1, 2013

@sskylar

This comment has been minimized.

Show comment
Hide comment
@sskylar

sskylar Nov 5, 2013

Others coming across this issue might find an answer here: http://effectif.com/ruby/installing-nokogiri-on-mavericks

I had this same issue since upgrading to Mavericks/Xcode 5 and fixed it by running xcode-select --install

👍

sskylar commented Nov 5, 2013

Others coming across this issue might find an answer here: http://effectif.com/ruby/installing-nokogiri-on-mavericks

I had this same issue since upgrading to Mavericks/Xcode 5 and fixed it by running xcode-select --install

👍

@kapso

This comment has been minimized.

Show comment
Hide comment
@kapso

kapso Nov 5, 2013

I get this error (http://cl.ly/image/2n2N2X301p1n) when trying to run xcode-select --install

So I downloaded/installed the command line tools from here - http://cl.ly/image/3J3Q0t2c3e1E

kapso commented Nov 5, 2013

I get this error (http://cl.ly/image/2n2N2X301p1n) when trying to run xcode-select --install

So I downloaded/installed the command line tools from here - http://cl.ly/image/3J3Q0t2c3e1E

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Dec 19, 2013

I also had the same issue, and solution was simple, just provide the CC environment argument :

http://www.quora.com/Mostafa-Ali-Mohamed/Posts/RVM-ruby-Installation-error-on-Mac

ghost commented Dec 19, 2013

I also had the same issue, and solution was simple, just provide the CC environment argument :

http://www.quora.com/Mostafa-Ali-Mohamed/Posts/RVM-ruby-Installation-error-on-Mac

@dranes

This comment has been minimized.

Show comment
Hide comment
@dranes

dranes Dec 19, 2013

👍 to @mostafaAli answer with osx 10.9 and trying to install ruby-1.9.3-p484

dranes commented Dec 19, 2013

👍 to @mostafaAli answer with osx 10.9 and trying to install ruby-1.9.3-p484

@yagudaev

This comment has been minimized.

Show comment
Hide comment
@yagudaev

yagudaev Feb 6, 2014

If you are trying to install 1.8.7-p375 doing brew install apple-gcc42 should solve your problem :). At least for me it did.

yagudaev commented Feb 6, 2014

If you are trying to install 1.8.7-p375 doing brew install apple-gcc42 should solve your problem :). At least for me it did.

@hiteshsharma

This comment has been minimized.

Show comment
Hide comment
@hiteshsharma

hiteshsharma Feb 20, 2014

I preferred using gcc instead of apple-gcc so I made a symlink to gcc
ln -s /usr/bin/gcc /usr/bin/gcc-apple-4.2

hiteshsharma commented Feb 20, 2014

I preferred using gcc instead of apple-gcc so I made a symlink to gcc
ln -s /usr/bin/gcc /usr/bin/gcc-apple-4.2

@aemadrid

This comment has been minimized.

Show comment
Hide comment
@aemadrid

aemadrid commented Aug 26, 2014

@jmervine

This comment has been minimized.

Show comment
Hide comment
@jmervine

jmervine Dec 17, 2014

@aemadrid's suggestion worked CC=gcc rbenv install <version>.

Also, for those that use port over brew, sudo port install apple-gcc42 works as well (except on Yosemite or later, but there's an open issue on that).

jmervine commented Dec 17, 2014

@aemadrid's suggestion worked CC=gcc rbenv install <version>.

Also, for those that use port over brew, sudo port install apple-gcc42 works as well (except on Yosemite or later, but there's an open issue on that).

@grantgeorge

This comment has been minimized.

Show comment
Hide comment
@grantgeorge

grantgeorge commented Aug 24, 2015

@yagudaev @hiteshsharma helped me, thanks ;)

@t0d0r

This comment has been minimized.

Show comment
Hide comment
@t0d0r

t0d0r Oct 27, 2015

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

t0d0r commented Oct 27, 2015

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
@mscottford

This comment has been minimized.

Show comment
Hide comment
@mscottford

mscottford Nov 13, 2015

@t0d0r: Thanks a bunch for posting your work around. Totally worked for me.

mscottford commented Nov 13, 2015

@t0d0r: Thanks a bunch for posting your work around. Totally worked for me.

@jinnko

This comment has been minimized.

Show comment
Hide comment
@jinnko

jinnko Jan 27, 2016

Following an upgrade to OSX 10.11 El Capitan, just the following command was needed:

xcode-select --install

Thanks to @t0d0r for the tip.

jinnko commented Jan 27, 2016

Following an upgrade to OSX 10.11 El Capitan, just the following command was needed:

xcode-select --install

Thanks to @t0d0r for the tip.

@slater1

This comment has been minimized.

Show comment
Hide comment
@slater1

slater1 May 18, 2016

I was trying to build vim and came to this page on the search term "C compiler cannot create executables"

The suggestion to use xcode-select was ineffective for me on OS X 10.10.5:

xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

However, calling ./configure and then make succeeded.

slater1 commented May 18, 2016

I was trying to build vim and came to this page on the search term "C compiler cannot create executables"

The suggestion to use xcode-select was ineffective for me on OS X 10.10.5:

xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

However, calling ./configure and then make succeeded.

@davidcpell

This comment has been minimized.

Show comment
Hide comment
@davidcpell

davidcpell Jan 11, 2017

@t0d0r's solution also worked for me, with slight alterations. I'm on OSX 10.12 so not sure if it's because of that or other points specific to my environment, but here are the notes I made:

$ brew install apple-gcc42
Error: No available formula with the name "apple-gcc42"
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
This formula was found in a tap:
homebrew/dupes/apple-gcc42
To install it, run:
  brew install homebrew/dupes/apple-gcc42

$ brew install homebrew/dupes/apple-gcc42
# Worked!
$ brew install openssl
Warning: openssl is a keg-only and another version is linked to opt.
Use `brew install --force` if you want to install this version

# Just skipped this one
$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

# Skipped

Did everything else as described.

davidcpell commented Jan 11, 2017

@t0d0r's solution also worked for me, with slight alterations. I'm on OSX 10.12 so not sure if it's because of that or other points specific to my environment, but here are the notes I made:

$ brew install apple-gcc42
Error: No available formula with the name "apple-gcc42"
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
This formula was found in a tap:
homebrew/dupes/apple-gcc42
To install it, run:
  brew install homebrew/dupes/apple-gcc42

$ brew install homebrew/dupes/apple-gcc42
# Worked!
$ brew install openssl
Warning: openssl is a keg-only and another version is linked to opt.
Use `brew install --force` if you want to install this version

# Just skipped this one
$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

# Skipped

Did everything else as described.

@vshy108

This comment has been minimized.

Show comment
Hide comment
@vshy108

vshy108 Mar 23, 2017

in my case, restart osx solved the problem.

vshy108 commented Mar 23, 2017

in my case, restart osx solved the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment