title: therubyracer - Gem::Ext::BuildError: ERROR: Failed to build gem native extension
body: <p>I'm trying to install the following gem versions on Mavericks</p>
  
  <ul>
  <li>libv8 (3.16.14.3)</li>
  <li>therubyracer (0.12.1)</li>
  </ul>
  
  <p>Obviously therubyracer gems depends on libv8.</p>
  
  <h1>1) Installing libv8</h1>
  
  <p>What is libv8? My bit of research seems to indicaite it's some sort of javascript library used by Google Chrome?</p>
  
  <p>I was having trouble installing it, but <a href="https://stackoverflow.com/questions/19577759/installing-libv8-gem-on-mavericks">this great post</a> had both my error and a well-explained answer on how to bypass it.</p>
  
  <p>So I installed <code>libv8</code> with</p>
  
  <pre><code>gem install libv8 -- --with-system-v8
  </code></pre>
  
  <p>It's my understanding that this installs the gem but uses my local system installation of the v8 library instead of... the version that comes with the gem? Either way, it was successful. </p>
  
  <h1>2) Installing therubyracer</h1>
  
  <p>During the next step, I had trouble install <code>therubyracer</code> gem. I'm not quite sure what this gem does, just that it's a dependency of a rails project I'm trying to <code>bundle install</code>.</p>
  
  <p>It gives me the following error:</p>
  
  <pre><code>Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
  
      /Users/jeeves.butler/.rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb 
  checking for main() in -lpthread... yes
  checking for main() in -lobjc... yes
  checking for v8.h... no
  *** 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
      --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=/Users/jeeves.butler/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
      --with-pthreadlib
      --without-pthreadlib
      --with-objclib
      --without-objclib
      --enable-debug
      --disable-debug
      --with-v8-dir
      --without-v8-dir
      --with-v8-include
      --without-v8-include=${v8-dir}/include
      --with-v8-lib
      --without-v8-lib=${v8-dir}/lib
  /Users/jeeves.butler/.rvm/gems/ruby-1.9.2-p290/gems/libv8-3.16.14.3/ext/libv8/location.rb:50:in 
  'configure': You have chosen to use the version of V8 found 
  on your system (Libv8::Location::System::NotFoundError)
  and *not* the one that is bundled with the libv8 rubygem. However,
  it could not be located. please make sure you have a version of
  v8 that is compatible with 3.16.14.3 installed. You may
  need to special --with-v8-dir options if it is in a non-standard
  location
  
  thanks,
  The Mgmt
  
      from /Users/jeeves.butler/.rvm/gems/ruby-1.9.2-p290/gems/libv8-3.16.14.3/lib/libv8.rb:7:in `configure_makefile'
      from extconf.rb:32:in `&lt;main&gt;'
  
  extconf failed, exit code 1
  
  Gem files will remain installed in /Users/jeeves.butler/.rvm/gems/ruby-1.9.2-p290/gems/therubyracer-0.12.1 for inspection.
  Results logged to /Users/jeeves.butler/.rvm/gems/ruby-1.9.2-p290/extensions/x86_64-darwin-13/1.9.1/therubyracer-0.12.1/gem_make.out
  </code></pre>
  
  <p>From what I can gather, I chose to install <code>libv8</code> using my local V8 library instead of what was provided with <code>libv8</code>, but now that local installation could not be located.</p>
  
  <ul>
  <li>How do I check if I do indeed have V8 installed and how do I locate it?</li>
  <li>I tried a few of the specified flags, none of them seemed to point the gem to the correct installation directory</li>
  <li>This might be a separate topic, but what is <code>extconf.rb</code>? I've seen it in a few places. And what's it trying to do with the <code>gcc</code> compiler in specific?</li>
  </ul>
  
  <p>Thanks!!</p>
  
  <p><strong>EDIT:</strong> </p>
  
  <ol>
  <li><p>I tried <a href="https://stackoverflow.com/a/19691782/2490003">this solution</a> of uninstalling libv8 and re-installing via <code>brew install</code>. It was mentioned in a couple of similar questions as well. No luck.</p></li>
  <li><p>I also tried the <code>CC</code>, <code>CXX</code>, and <code>CPP</code> environment variables as described <a href="http://www.computersnyou.com/2673/2013/10/install-ruby-rails-macos-x-mavericks-10-9-mysql-step-step/" rel="noreferrer">here</a>, although I don't think that has any effect as it was already picking up my <code>gcc v4.6</code> compiler.</p></li>
  </ol>