You Have To Install Development Tools First
It appears, at first, to be a very dignified error message, very poised in telling you what exactly needs to happen and here you are thinking, oh look, it tells me what I have to do. Don’t let that fool you, I spent the better part of a evening trying to get past the above message.
Here is my stack trace:
Building native extensions. This could take a while...
ERROR: Error installing adhearsion:
ERROR: Failed to build gem native extension.
/home/karthicr/.rvm/rubies/ruby-2.0.0-p247/bin/ruby extconf.rb
checking for pcre.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/home/karthicr/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
/home/karthicr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:430:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /home/karthicr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:561:in `try_cpp'
from /home/karthicr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:1085:in `block in find_header'
from /home/karthicr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:891:in `block in checking_for'
from /home/karthicr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:336:in `block (2 levels) in postpone'
from /home/karthicr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:306:in `open'
from /home/karthicr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:336:in `block in postpone'
from /home/karthicr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:306:in `open'
from /home/karthicr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:332:in `postpone'
from /home/karthicr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:890:in `checking_for'
from /home/karthicr/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/mkmf.rb:1084:in `find_header'
from extconf.rb:5:in `<main>'
Gem files will remain installed in /home/karthicr/.rvm/gems/ruby-2.0.0-p247/gems/ruby_speech-2.3.0 for inspection.
Results logged to /home/karthicr/.rvm/gems/ruby-2.0.0-p247/gems/ruby_speech-2.3.0/ext/ruby_speech/gem_make.out
Long story short, I was trying to install adhearsion on my laptop running Ubuntu 12.04 LTS. I had never worked on ruby before so I set about installing:
- rvm (using curl)
- ruby (using rvm)
- rubygems (using rvm)
- adhearsion (using gem)
I was having trouble getting ruby_speech (an adhearsion dependency) compiled. After loads of googling and installing all sorts of packages you think will help you get past this error, I finally found the solution documented here: Can’t install ruby_speech gem, checking for pcre.h… no
All you need is this:
sudo apt-get install libpcre3 libpcre3-dev
And you are scott free! Cheers and happy coding!