麻烦安装pg gem [英] Trouble installing pg gem

查看:147
本文介绍了麻烦安装pg gem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试安装pg gem会给我带来错误。



我使用的是使用rbenv / ruby​​-build构建的Ruby 1.9.3-p125。我使用一键式安装程序安装了PostgreSQL。我可以使用pgAdmin连接到数据库。

 %gem install pg〜
构建原生扩展。这可能需要一段时间...
错误:安装pg时出错:
错误:无法构建gem本机扩展。

/Users/sandropadin/.rbenv/versions/1.9.3-p125/bin/ruby extconf.rb
检查pg_config ...是
使用来自/ usr / bin / pg_config
检查libpq-fe.h ...是
检查libpq / libpq-fs.h ...是
检查pg_config_manual.h ...是
在-lpq中检查PQconnectdb()...是
检查PQconnectionUsedPassword()...是
检查PQisthreadsafe()...是
检查PQprepare() )...是
检查PQexecParams()...是
检查PQescapeString()...是
检查PQescapeStringConn()...是
检查PQgetCancel()...是
检查lo_create()...是
检查pg_encoding_to_char()...是
检查pg_char_to_encoding()...是
检查PQsetClientEncoding()...是
检查rb_encdb_alias()...是
检查rb_enc_alias()...是
检查libpq-fe中的struct pgNotify.extra。 h ...是
检查unistd.h ...是
chec king for ruby​​ / st.h ...是
创建extconf.h
创建Makefile
$ b $ make make
编译pg.c
编译pg_connection.c
pg_connection.c:函数'pgconn_wait_for_notify':
pg_connection.c:1986:警告:'rb_thread_select'已被弃用(在/Users/sandropadin/.rbenv/versions/1.9.3-p125/处声明) include / ruby​​-1.9.1 / ruby​​ / intern.h:379)
pg_connection.c:函数'pgconn_block':
pg_connection.c:2512:警告:'rb_thread_select'已弃用/Users/sandropadin/.rbenv/versions/1.9.3-p125/include/ruby-1.9.1/ruby/intern.h:379)
编译pg_result.c
链接共享对象pg_ext。 bundle
ld:在/usr/local/lib/libssl.0.9.8.dylib中,缺少架构x86_64所需的体系结构x86_64文件
collect2:ld返回1退出状态
make:* ** [pg_ext.bundle]错误1


Gem文件将保留安装在/Users/sandropadin/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9 .1 / gems / pg-0.13.2 for i nspection。
记录到/Users/sandropadin/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/pg-0.13.2/ext/gem_make.out
的结果


解决方案

不知道以下哪个步骤最终解决了这个问题。但是由于mu提到的太短,问题在于混合了32位和64位二进制文​​件。


  • 1,我安装了这个 PostgreSQL的64位版本
  • 2,我卸载了任何旧版的Homebrew OpenSSL安装
    $ b


    <$> $ brew卸载openssl




    $ brew install --64位openssl

    p>


  • 最后,在安装pg gem时,我将LDFLAGS更改为指向64位版本的OpenSSL


    $ gem install pg - --with-ldflags =' - L / usr / local / Cellar / openssl / 0.9.8s'




Trying to install the pg gem gives me errors.

I'm using Ruby 1.9.3-p125 built using rbenv/ruby-build. I installed PostgreSQL using the one-click installer. I'm able to connect to the DB using pgAdmin. I'm running out of ideas.

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

        /Users/sandropadin/.rbenv/versions/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... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... yes
checking for PQconnectionUsedPassword()... yes
checking for PQisthreadsafe()... yes
checking for PQprepare()... yes
checking for PQexecParams()... yes
checking for PQescapeString()... yes
checking for PQescapeStringConn()... yes
checking for PQgetCancel()... yes
checking for lo_create()... yes
checking for pg_encoding_to_char()... yes
checking for pg_char_to_encoding()... yes
checking for PQsetClientEncoding()... yes
checking for rb_encdb_alias()... yes
checking for rb_enc_alias()... yes
checking for struct pgNotify.extra in libpq-fe.h... yes
checking for unistd.h... yes
checking for ruby/st.h... yes
creating extconf.h
creating Makefile

make
compiling pg.c
compiling pg_connection.c
pg_connection.c: In function ‘pgconn_wait_for_notify’:
pg_connection.c:1986: warning: ‘rb_thread_select’ is deprecated (declared at /Users/sandropadin/.rbenv/versions/1.9.3-p125/include/ruby-1.9.1/ruby/intern.h:379)
pg_connection.c: In function ‘pgconn_block’:
pg_connection.c:2512: warning: ‘rb_thread_select’ is deprecated (declared at /Users/sandropadin/.rbenv/versions/1.9.3-p125/include/ruby-1.9.1/ruby/intern.h:379)
compiling pg_result.c
linking shared-object pg_ext.bundle
ld: in /usr/local/lib/libssl.0.9.8.dylib, missing required architecture x86_64 in file for architecture x86_64
collect2: ld returned 1 exit status
make: *** [pg_ext.bundle] Error 1


Gem files will remain installed in /Users/sandropadin/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/pg-0.13.2 for inspection.
Results logged to /Users/sandropadin/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/pg-0.13.2/ext/gem_make.out

解决方案

Not sure which of the following steps finally cleared this issue up. But as mu is too short mentioned, the problem was mixing 32bit and 64bit binaries.

  • 1st, I installed this 64-bit version of PostgreSQL
  • 2nd, I uninstalled any old Homebrew OpenSSL installation

    $ brew uninstall openssl

  • 3rd, I installed the 64-bit version of OpenSSL with Homebrew

    $ brew install --64-bit openssl

  • Lastly, when installing the pg gem, I changed the LDFLAGS to point to the 64-bit version of OpenSSL

    $ gem install pg -- --with-ldflags='-L/usr/local/Cellar/openssl/0.9.8s'

这篇关于麻烦安装pg gem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆