title: Installing pg gem; ERROR: Failed to build gem native extension
body: <p>After updating to <strong>OS X 10.9 Mavericks</strong> I tried to start a Rails 3 app, but the connection to the PG database was not working. Checking on PGAdmin III, the database is still there and it works fine.
  So I tried to reinstall the pg gem:</p>
  
  <pre><code>gem uninstall pg
  gem install pg
  </code></pre>
  
  <p>But the last command doesn't succeed, and gives the following error:</p>
  
  <blockquote>
    <p>Building native extensions.  This could take a while... ERROR:  Error
    installing pg:    </p>
    
    <p>ERROR: Failed to build gem native extension.</p>
  
  <pre><code>    /Users/XXX/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb checking for pg_config... yes Using config values from
  </code></pre>
    
    <p>/usr/local/bin/pg_config
    <strong>* extconf.rb failed *</strong> 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.</p>
    
    <p>/Users/XXX/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:381:in
    `try_do': The compiler failed to generate an executable file.</p>
    
    <p>(RuntimeError) You have to install development tools first.   from
    /Users/XXX/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:461:in
    <code>try_link0'   from
    /Users/XXX/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:476:in
    </code>try_link'    from extconf.rb:39:in `'</p>
  </blockquote>
  
  <p>I guess the problem is related to the <strong>Xcode developer tools</strong>. I updated Xcode to the latest version, but that didn't solve the problem. Do you know how to fix it?</p>