加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 无法在Windows 7上安装MySQL2 gem

发布时间:2020-12-16 20:34:44 所属栏目:百科 来源:网络整理
导读:我在安装时收到以下错误信息,让我知道如果我需要发布更多的细节. 我遵循以下位置的指示: https://github.com/oneclick/rubyinstaller/wiki/Development-Kit 我使用的是ruby 1.9.2p136(2010-12-25)[i386-mingw32]. 这是我得到的: E:work_desktrunkgem ins
我在安装时收到以下错误信息,让我知道如果我需要发布更多的细节.

我遵循以下位置的指示:
https://github.com/oneclick/rubyinstaller/wiki/Development-Kit

我使用的是ruby 1.9.2p136(2010-12-25)[i386-mingw32].

这是我得到的:

E:work_desktrunk>gem install mysql2 -v 0.2.4
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
        ERROR: Failed to build gem native extension.

C:/Ruby192/bin/ruby.exe extconf.rb
checking for rb_thread_blocking_region()... yes
checking for main() in -llibmysql... no
*** 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=C:/Ruby192/bin/ruby
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include
        --without-mysql-include=${mysql-dir}/include
        --with-mysql-lib
        --without-mysql-lib=${mysql-dir}/lib
        --with-libmysqllib
        --without-libmysqllib


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

解决方法

您要安装的特定版本的mysql2 gem(0.2.4)不仅缺少Windows的二进制文件,而且在Windows上有问题.

请安装mysql2 gem而不指示版本:

gem install mysql2

哪个将安装最新版本(在我发布时为0.2.6),并且还提供了跳过编译步骤的Windows的二进制文件.

如果您仍然希望强制编译(因为您的MySQL版本与用于生成二进制gem的版本不同),则需要从RubyInstaller网站安装RubyInstaller的DevKit:

http://rubyinstaller.org/downloads

并从维基(从下载页面链接)的DevKit installation instructions

您将需要在gem安装过程中为头文件和库提供路径,并从以下说明中调整MySQL安装位置:

subst X: "C:Program Files (x86)MySQLMySQL Server 5.1" 
gem install mysql2 --platform=ruby -- --with-mysql-dir=X: --with-mysql-lib=X:libopt 
subst X: /D

上面的命令使用subst来避免使用空格的路径问题,你应该总是避免.

希望这可以帮助.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读