2012-07-22 127 views
0

我在Mac OS 10.7.4上,并且安装了最新版本的Xcode和命令行工具。gem install pg error,Mac Lion

我得到一个错误(如下图所示),当我尝试 “创业板安装PG”:

gem install pg 
Building native extensions. This could take a while... 
ERROR: Error installing pg: 
    ERROR: Failed to build gem native extension. 

/Users/rdp/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb 
checking for pg_config... yes 
Using config values from /usr/bin/pg_config 
checking for libpq-fe.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 
    --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/rdp/.rvm/rubies/ruby-1.9.3-p125/bin/ruby 
    --with-pg 
    --without-pg 
    --with-pg-dir 
    --without-pg-dir 
    --with-pg-include 
    --without-pg-include=${pg-dir}/include 
    --with-pg-lib 
    --without-pg-lib=${pg-dir}/lib 
    --with-pg-config 
    --without-pg-config 
    --with-pg_config 
    --without-pg_config 
/Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError) 
You have to install development tools first. 
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp' 
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:970:in `block in find_header' 
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for' 
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone' 
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:254:in `open' 
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone' 
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:254:in `open' 
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:280:in `postpone' 
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for' 
    from /Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/mkmf.rb:969:in `find_header' 
    from extconf.rb:41:in `<main>' 


Gem files will remain installed in /Users/rdp/.rvm/gems/ruby-1.9.3-p125/gems/pg-0.14.0 for inspection. 
Results logged to /Users/rdp/.rvm/gems/ruby-1.9.3-p125/gems/pg-0.14.0/ext/gem_make.out 

这是我mkmf.log文件的内容:

find_executable: checking for pg_config... -------------------- yes 

-------------------- 
"/usr/bin/gcc-4.2 -o conftest -I/Users/rdp/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/x86_64-darwin11.3.0 -I/Users/rdp/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1/ruby/backward -I/Us\ 
ers/rdp/.rvm/rubies/ruby-1.9.3-p125/include/ruby-1.9.1 -I. -I/Users/rdp/.rvm/usr/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/usr/include -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-pa\ 
rentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -fno-common -pipe \ 
conftest.c -L. -L/Users/rdp/.rvm/rubies/ruby-1.9.3-p125/lib -L/Users/rdp/.rvm/usr/lib -L. -L/usr/lib  -lruby.1.9.1 -lpthread -ldl -lobjc " 
checked program was: 
/* begin */ 
1: #include "ruby.h" 
2: 
3: int main() {return 0;} 
/* end */ 

回答

0

开始的XCode,去根据偏好,转到下载并安装命令行工具

+0

我已经安装了命令行工具。 – 2012-07-22 08:40:48

+0

事实证明,我需要安装更新版本的GCC:https://github.com/kennethreitz/osx-gcc-installer/。此安装使我可以从Xcode首选项下载命令行工具,并且'gem install pg'工作正常! – 2012-07-22 20:15:36