簡體   English   中英

為PostgreSQL安裝gem pg,openssl庫

[英]Installing gem pg for PostgreSQL, openssl libraries

我正在使用RVM與ruby 2.0.0。 當我嘗試為PostgreSQL安裝pg gem時,我得到以下響應。

寶石安裝pg

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

    /usr/local/rvm/rubies/ruby-2.0.0-p0/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... 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 ***
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
    --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=/usr/local/rvm/rubies/ruby-2.0.0-p0/bin/ruby
    --with-pg
    --without-pg
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config
    --with-pqlib
    --without-pqlib
    --with-libpqlib
    --without-libpqlib
    --with-ms/libpqlib
    --without-ms/libpqlib


Gem files will remain installed in /usr/local/rvm/gems/ruby-2.0.0-p0/gems/pg-0.14.1 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.0.0-p0/gems/pg-0.14.1/ext/gem_make.out

試圖谷歌為它,顯然問題是OpenSSL庫,因為在mkmf.log輸出是

have_library: checking for PQconnectdb() in -lpq... -----------------$

"gcc -o conftest -I/usr/local/rvm/rubies/ruby-2.0.0-p0/include/ruby-2$
conftest.c: In function 't':
conftest.c:8:32: warning: variable 'p' set but not used [-Wunused-but$
/usr/lib/libpq.so: undefined reference to `SSL_get_error@OPENSSL_1.0.$
/usr/lib/libpq.so: undefined reference to `SSL_get_peer_certificate@O$
/usr/lib/libpq.so: undefined reference to `SSL_CTX_load_verify_locati$
/usr/lib/libpq.so: undefined reference to `SSL_set_ex_data@OPENSSL_1.$
/usr/lib/libpq.so: undefined reference to `SSL_use_certificate_file@O$
/usr/lib/libpq.so: undefined reference to `ENGINE_free@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_write@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `ERR_get_error@OPENSSL_1.0.$
/usr/lib/libpq.so: undefined reference to `ENGINE_by_id@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_use_PrivateKey@OPENSSL$
/usr/lib/libpq.so: undefined reference to `X509_get_subject_name@OPEN$
/usr/lib/libpq.so: undefined reference to `ENGINE_init@OPENSSL_1.0.0'
/usr/lib/libpq.so: undefined reference to `SSL_load_error_strings@OPE$
/usr/lib/libpq.so: undefined reference to `X509_STORE_set_flags@OPENS$
/usr/lib/libpq.so: undefined reference to `SSL_new@OPENSSL_1.0.0'

然后我使用指定的OpenSSL目錄重新安裝ruby

openssl version -d
OPENSSLDIR: "/usr/lib/ssl"
rvm reinstall 2.0.0 --with-openssl-dir=/usr/lib/ssl

還是同樣的問題。

嘗試使用--with-pg-config標志來安裝gem。 同樣的問題。

嘗試在許多網站上找到的常見解決方法

mv $rvm_path/usr/lib $rvm_path/usr/rvm_lib
gem install pg
mv $rvm_path/usr/rvm_lib $rvm_path/usr/lib

但這次錯誤是不同的。

寶石安裝pg

Error loading RubyGems plugin "/usr/local/rvm/gems/ruby-2.0.0-p0@global/gems/rubygems-bundler-1.1.1/lib/rubygems_plugin.rb": /usr/local/rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/x86_64-linux/openssl.so: undefined symbol: SSLv2_method - /usr/local/rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/x86_64-linux/openssl.so (LoadError)
ERROR:  Loading command: install (LoadError)
    /usr/local/rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/x86_64-linux/openssl.so: undefined symbol: SSLv2_method - /usr/local/rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/x86_64-linux/openssl.so
ERROR:  While executing gem ... (NoMethodError)
    undefined method `invoke_with_build_args' for nil:NilClass

假設它仍然試圖從Ruby目錄中獲取openssl.so - 問題在於Ruby使用了錯誤的openssl.so文件。 但事實是,我用--with-openssl-dir標志重新編譯了它。

有什么建議嗎? 我真的堅持了前10個小時嘗試我能找到的每個解決方法。

為什么會一直發生? 只要您在此處發布問題,就可以自行解決問題。

解決方案很簡單 - 重新安裝ruby時我錯過了“ - ”。

openssl version -d
OPENSSLDIR: "/usr/lib/ssl"
rvm reinstall 2.0.0 -- --with-openssl-dir=/usr/lib/ssl

這解決了這個問題。 希望它會幫助別人。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM