我已经尝试了一整晚,但到目前为止仍然无法在我的 Debian Testing 64Bit 系统上为 ruby 编译 mysql gem。
我相信这是因为我安装了 openssl v1.0.0 库。
这是我尝试安装时得到的结果(使用 RVM 1.14.7 和 Ruby 1.9.1p431):
gem install mysql
Building native extensions. This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
/home/jarrett/.rvm/rubies/ruby-1.9.1-p431/bin/ruby extconf.rb
checking for mysql_ssl_set()... *** 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=/home/jarrett/.rvm/rubies/ruby-1.9.1-p431/bin/ruby
--with-mysql-config
--without-mysql-config
/home/jarrett/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/mkmf.rb:364:in `try_do': The complier failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /home/jarrett/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/mkmf.rb:417:in `try_link0'
from /home/jarrett/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/mkmf.rb:421:in `try_link'
from /home/jarrett/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/mkmf.rb:529:in `try_func'
from /home/jarrett/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/mkmf.rb:774:in `block in have_func'
from /home/jarrett/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/mkmf.rb:670:in `block in checking_for'
from /home/jarrett/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/mkmf.rb:276:in `block (2 levels) in postpone'
from /home/jarrett/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/mkmf.rb:250:in `open'
from /home/jarrett/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/mkmf.rb:276:in `block in postpone'
from /home/jarrett/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/mkmf.rb:250:in `open'
from /home/jarrett/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/mkmf.rb:272:in `postpone'
from /home/jarrett/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/mkmf.rb:669:in `checking_for'
from /home/jarrett/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/mkmf.rb:773:in `have_func'
from extconf.rb:45:in `<main>'
Gem files will remain installed in /home/jarrett/.rvm/gems/ruby-1.9.1-p431/gems/mysql-2.9.1 for inspection.
Results logged to /home/jarrett/.rvm/gems/ruby-1.9.1-p431/gems/mysql-2.9.1/ext/mysql_api/gem_make.out
当我检查 mkmf.log 文件(位于/home/jarrett/.rvm/gems/ruby-1.9.1-p431/gems/mysql-2.9.1/ext/mysql_api/mkmf.log
)时,它是空的。
我尝试过的方法
1)确保安装了所有必需的开发包(libssl-dev libopenssl-ruby build-essential gcc autoconf automake libmysql-ruby ruby-mysql libmysqld-dev ruby-dev libmysql++-dev libmysqlclient-dev)
2) 我最初安装了较新的 RVM - 我将其卸载并重新安装了较早版本的 RVM。我这样做了(遵循以下说明:https://stackoverflow.com/questions/13366409/undefined-symbol-sslv2-method-when-trying-to-run-thin-webserver) 希望我可以运行rvm pkg install openssl
(本地安装了 openssl 0.9.8),然后使用以下命令安装 ruby:rvm install 1.9.1 --with-openssl-dir=/home/jarrett/.rvm/usr
。我希望这将使用 0.9.8 版本的 openssl。没有成功。
3) 尝试将本地 openssl 0.9.8 导出到LD_LIBRARY_PATH
with export LD_LIBRARY_PATH=/home/jarrett/.rvm/usr/lib
,然后再次运行安装。没有成功。
4) 通过 RVM 安装 ruby 1.9.2 和 1.9.3 并尝试。没有成功。
5) 对着电脑大声吼叫。没用。
有人有什么想法/建议吗?
也许 mysql gem 很快就会更新为使用 openssl 1.0.0?
答案1
mkmf 是 ruby-dev 包的一部分。
你需要做
sudo apt-get install ruby1.9.1-dev
然后尝试安装 gem mysql。
编辑:抱歉,我错过了。您也可以尝试安装“mysql-devel”。
答案2
无法弄清楚,所以我按照这些说明安装了 openssl 0.9.8(https://stackoverflow.com/questions/13366409/undefined-symbol-sslv2-method-when-trying-to-run-thin-webserver和https://rvm.io/packages/openssl/),然后安装了 mysql2 gem 并使用它来代替。