【问题标题】:Trouble installing pg gem安装 pg gem 时遇到问题
【发布时间】:2012-03-23 21:47:19
【问题描述】:

尝试安装 pg gem 时出现错误。

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

% 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

【问题讨论】:

  • 你从哪里得到你的 libssl?听起来您可能正在尝试混合 32 位和 64 位二进制文​​件。
  • 我认为只是使用brew install openssl
  • 我认为您将两者混合是正确的,但我不知道是否有可能或如何强制 Homebrew 将 openssl 构建为 64 位

标签: ruby macos postgresql rubygems osx-lion


【解决方案1】:

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

  • 第一,我安装了这个64-bit version of PostgreSQL
  • 第二,我卸载了任何旧的 Homebrew OpenSSL 安装

    $ brew uninstall openssl

  • 第三,我用 Homebrew 安装了 64 位版本的 OpenSSL

    $ brew install --64-bit openssl

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

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

【讨论】:

  • 我必须说我一直在努力让pg gem 在我的 Lion 副本上编译大约 6 个月。现在这个答案出现了,我能够像冠军一样运行 Rails 3.2 + PostgreSQL。谢谢!
  • 这对我有用 Mountain Lion, ruby​​ 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.0.0]。我使用了brew install postgresql,还没有openssl,所以只使用brew install --64-bit openssl,然后使用它提供的LDFLAGS。
  • 效果很好,除了 openssl 的版本已经更新(现在是 1.0.1c)。用户需要 cd /usr/local/Cellar/openssl/ 并运行 ls 以查看其版本号
猜你喜欢
  • 1970-01-01
  • 2015-07-12
  • 1970-01-01
  • 2013-11-05
  • 1970-01-01
  • 2011-08-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多