错误为PostgreSQL安装ruby gem

时间:2010-08-02 21:12:19

标签: ruby-on-rails ruby postgresql rubygems install

我正在尝试配置rails服务器以使用PostgreSQL,但在安装postgres gem时卡住了。我已经在机器上成功安装了PostgreSQL(并且可以将它用于其他应用程序)但是在尝试为它安装ruby gem时出现错误。

我这样做:sudo gem install postgres

获得以下输出:

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

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for main() in -lpq... yes
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for PQsetClientEncoding()... no
checking for pg_encoding_to_char()... no
checking for PQfreemem()... no
checking for PQserverVersion()... no
checking for PQescapeString()... no
creating Makefile

make
gcc -I. -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin10.0 -I. -DHAVE_LIBPQ_FE_H -DHAVE_LIBPQ_LIBPQ_FS_H -I/Library/PostgreSQL/8.4/include  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE  -fno-common  -pipe -fno-common   -c libpq-compat.c
libpq-compat.c: In function ‘PQescapeBytea’:
libpq-compat.c:104: warning: incompatible implicit declaration of built-in function ‘sprintf’
libpq-compat.c: In function ‘PQunescapeBytea’:
libpq-compat.c:158: warning: incompatible implicit declaration of built-in function ‘strlen’
libpq-compat.c: In function ‘PQescapeBytea’:
libpq-compat.c:104: warning: incompatible implicit declaration of built-in function ‘sprintf’
libpq-compat.c: In function ‘PQunescapeBytea’:
libpq-compat.c:158: warning: incompatible implicit declaration of built-in function ‘strlen’
gcc -I. -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin10.0 -I. -DHAVE_LIBPQ_FE_H -DHAVE_LIBPQ_LIBPQ_FS_H -I/Library/PostgreSQL/8.4/include  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE  -fno-common  -pipe -fno-common   -c postgres.c
postgres.c:41: error: static declaration of ‘PQserverVersion’ follows non-static declaration
/Library/PostgreSQL/8.4/include/libpq-fe.h:289: error: previous declaration of ‘PQserverVersion’ was here
postgres.c: In function ‘Init_postgres’:
postgres.c:2676: error: ‘pgconn_protocol_version’ undeclared (first use in this function)
postgres.c:2676: error: (Each undeclared identifier is reported only once
postgres.c:2676: error: for each function it appears in.)
postgres.c:2677: error: ‘pgconn_server_version’ undeclared (first use in this function)
postgres.c:41: error: static declaration of ‘PQserverVersion’ follows non-static declaration
/Library/PostgreSQL/8.4/include/libpq-fe.h:289: error: previous declaration of ‘PQserverVersion’ was here
postgres.c: In function ‘Init_postgres’:
postgres.c:2676: error: ‘pgconn_protocol_version’ undeclared (first use in this function)
postgres.c:2676: error: (Each undeclared identifier is reported only once
postgres.c:2676: error: for each function it appears in.)
postgres.c:2677: error: ‘pgconn_server_version’ undeclared (first use in this function)
lipo: can't open input file: /var/tmp//ccpTMtE2.out (No such file or directory)
make: *** [postgres.o] Error 1


Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/postgres-0.7.9.2008.01.28 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/postgres-0.7.9.2008.01.28/ext/gem_make.out

我使用的是Mac OS 10.6.4和Postgres版本8.4。

想一想这里会发生什么或如何解决它?

1 个答案:

答案 0 :(得分:2)

看起来您正在使用Postgres的EnterpriseDB发行版,您需要在Snow Leopard上执行此操作:

$ export ARCHFLAGS='-arch i386'
$ sudo gem install pg -- --with-pg-config=/Library/PostgreSQL/8.4/bin/pg_config