我有:
- Ubuntu 11.10
- Postgres 8.4
- 安装了 libpq-dev,build-essential
- ruby 1.9.2 和 rails 3.2.1 通过 rvm 安装
但是,pg gem 构建失败,表示:
checking for pg_config... yes
Using config values from /usr/lib/postgresql/8.4/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 ***
我知道这个问题被问了很多次,但我用谷歌搜索了 2 天,并尝试了我遇到的所有解决方案,但这个 gem 仍然无法构建。
有什么想法吗?
最佳答案
今天我在 Ubuntu 10.04 上遇到了一个非常相似的问题。 在尝试安装 pg 半天之后,我决定手动安装更新版本的 postgresql - 这解决了我的问题。
这是我做的:
1) 从他们的网站获取 postgresql 源代码。由于我将我的 rails 应用程序部署到 heroku,他们说他们使用 9.0 版的 postgresql atm,所以我下载了
http://ftp.postgresql.org/pub/source/v9.0.6/postgresql-9.0.6.tar.gz
2) 解压缩,然后按照 INSTALL 文件中的说明进行操作。请注意,在 Ubuntu 中,'su' 将被替换为 'sudo su'。之后,您在/usr/local/pgsql/中安装了一个 postgresql 服务器。
3) 如果您已经有一个名为“postgres”的系统用户,您可能希望将其主目录更改为新的 postgres 安装目录。您可能想将/usr/local/pgsql/bin 添加到您的 PATH 中。也许在从源代码安装 9.0 版本之前通过 apt-get 卸载 postgresql-8.4 是个好主意,我没有尝试过。
第一个
关于postgresql - 无法构建 pg gem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9259735/