ruby-on-rails – 无法安装pg gem,检查-lpq中的PQconnectdb()…否

我正在尝试使用Postgresql本地开发 Ruby on Rails,所以我正在尝试安装pg gem.在Ubuntu 12.04上.在终端,我输入:
gem install pg -v '0.12.2'

这会引发以下错误

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

        /home/troyshu/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the Postgresql client library (libpq)
*** 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=/home/troyshu/.rvm/rubies/ruby-1.9.3-p194/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
    --with-pqlib
    --without-pqlib
    --with-libpqlib
    --without-libpqlib
    --with-ms/libpqlib
    --without-ms/libpqlib


Gem files will remain installed in /home/troyshu/.rvm/gems/ruby-1.9.3-p194/gems/pg-0.14.1 for inspection.
Results logged to /home/troyshu/.rvm/gems/ruby-1.9.3-p194/gems/pg-0.14.1/ext/gem_make.out

有趣的是,在命令中添加sudo可以:

$sudo gem install pg -v '0.12.2'
Building native extensions.  This Could take a while...
Successfully installed pg-0.12.2
1 gem installed

顺便说一句,我必须运行“sudo apt-get install ruby​​1.9.1-dev”才能使上述命令生效.但我仍然无法进行任何开发,因为“捆绑安装”不起作用(并一直告诉我运行’gem install pg -v’0.12.2′)

我有一种感觉“宝石安装pg”正在被绊倒

checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no

但是,作为Ubuntu和RoR的完整菜鸟,我不知道为什么.也许我的搜索技巧也很臭,因为我无法找到解决我特定情况的方法.希望有一个修复?

谢谢!

解决方法

相关: gem install pg can not bind to libpq.请检查你的mkmf日志并查找libssl的错误.我有同样的问题.我安装了libpq-dev并仔细检查了pg_config.似乎gem找到了libpq-dev头文件,但无法与libpq链接​​.事实证明,rvm为ssl安装的软件包以某种方式干扰了通过libssl-dev安装的软件包.

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...