我有两个Ruby版本:1.8.7、1.9.2和PostgreSQL 8.3.我不能在任何一个上面安装pg gem.获取此错误:

C:/Development/Ruby187/bin/ruby.exe extconf.rb
checking for pg_config... yes
not recorded
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** 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
 --without-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=C:/Development/Ruby187/bin/ruby
 --with-pg
 --without-pg
 --with-pg-config
 --without-pg-config
 --with-pg-dir
 --without-pg-dir
 --with-pg-include
 --without-pg-include=${pg-dir}/include
 --with-pg-lib
 --without-pg-lib=${pg-dir}/lib

我知道这是一个常见的问题,但我还没有找到任何有效的解决方案...哦,我在路径中添加了C:\Program Files(x86)\PostgreSQL\8.3\bin.

推荐答案

你得到的信息清楚地表明,你缺少正确安装该gem的东西:

由于某些原因无法创建Makefile,可能是缺少

昨天发布的最新版本的pg(0.10.0)没有Windows本机版本,但如果安装0.9.0,它应该安装二进制文件而不会出现问题.

无论如何,如果你想安装gem,你需要安装一个构建环境.如果你用的是RubyInstaller,那么你需要DevKit

安装gem只需要提供gem安装的附加选项(比如--with-pg-dir)

subst X: "C:\Program Files (x86)\PostgreSQL\8.3"
gem install pg -- --with-pg-dir=X:
subst X: /D

Postgresql相关问答推荐

"错误:无法创建用户:错误:关系\users\违反了非空约束

Postgres 13.8 -如何在对数据执行窗口操作时返回所有行

在Go中,如何在没有数据库包的情况下运行PostgreSQL查询?

如何确定要与给定转储文件一起使用的pg_Restore版本?

自左联接的POSTGIS更新

错误:用户需要系统密码:postgres

使用 pgx 扫描范围类型

将数组的所有元素循环到jsonb中并修改值

如何在postgresql中按时间查询

PostgreSQL SELECT 结果具有不同的 id,它更喜欢来自另一个表的特定值

PostgreSQL错误致命:角色 username不存在

安装 pg gem 失败,mkmf.rb 找不到 ruby​​ 的头文件(Mac OSX 10.6.5)

Rails:安装 pg gem 时出错

如何将 DELETE 的返回值插入到 postgresql 中的 INSERT 中?

在 PostgreSQL 中将时间转换为秒

Rails ActiveRecord - 如何获取两个日期之间的记录

如何使用 WITH RECURSIVE 子句进行 Select

Windows 上的 GeoDjango:Could not find the GDAL library" / "OSError: [WinError 126] The specified module could not be found

PostgreSQL 无法启动:server.key具有组或世界访问权限

Django 中的唯一模型字段和区分大小写(postgres)