Ruby   发布时间:2022-04-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Ruby gem mysql2安装错误大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我在 Windows7中安装了 Ruby版本的ruby 1.9.2p0(2010-08-18)[i386-mingw32].
和宝石血统1.3.7

我试图安装mysql gem时,显示无法构建gem本机扩展错误,为什么会这样?我的mysql版本是5.1.36(WampServer)

E:\RubyApps\test_app2>gem install mysql2
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
        ERROR: Failed to build gem native extension.

E:/Ruby192/bin/ruby.exe extconf.rb
checking for rb_thread_blocking_region()... *** 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
        --without-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=E:/Ruby192/bin/ruby
E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:368:in `try_do': The complier failed to genera
te an executable file. (RuntimeError)
You have to install development tools first.
        from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:435:in `try_link0'
        from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:440:in `try_link'
        from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:552:in `try_func'
        from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:797:in `block in have_func'
        from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:693:in `block in checking_for'
        from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:280:in `block (2 levels) in postp
one'
        from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:254:in `open'
        from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:280:in `block in postpone'
        from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:254:in `open'
        from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:276:in `postpone'
        from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:692:in `checking_for'
        from E:/Ruby192/lib/ruby/1.9.1/mkmf.rb:796:in `have_func'
        from extconf.rb:9:in `<main>'


Gem files will remain installed in E:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.
2.3 for inspection.
Results logged to E:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.3/ext/mysql2/ge
m_make.out

E:\RubyApps\test_app2>

解决方法

由于这不断在谷歌上出现在顶级的结果,我应该指出,这个答案是从近两年前.这是一个更新的答案: How to use “mysql2” gem in Rails 3 application on Windows 7?

根据开发人员的说法,已经有一个报告的错误,他正在努力将mysql2分配到Windows.到目前为止 – 它仍然在作品中.现在使用较旧的mysql驱动程序 – 或者使用SQLite进行本地开发.

这是从googlegroups讨论

大佬总结

以上是大佬教程为你收集整理的Ruby gem mysql2安装错误全部内容,希望文章能够帮你解决Ruby gem mysql2安装错误所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。