无法在 Windows 7 上安装 MySQL2 gem [英] Unable to install MySQL2 gem on Windows 7

查看:27
本文介绍了无法在 Windows 7 上安装 MySQL2 gem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在安装时收到以下错误消息,如果我需要发布更多详细信息,请告诉我.

I am getting the following error message while installing, let me know if I need to post more details.

我按照以下位置的说明进行操作:https://github.com/oneclick/rubyinstaller/wiki/Development-Kit

I followed instructions from the following location: https://github.com/oneclick/rubyinstaller/wiki/Development-Kit

我正在使用 ruby​​ 1.9.2p136 (2010-12-25) [i386-mingw32].

I am using ruby 1.9.2p136 (2010-12-25) [i386-mingw32].

这是我得到的:

E:work_desk	runk>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 上也存在问题.

The specific version of mysql2 gem you're trying to install (0.2.4) not only lacks binaries for Windows, but have issues on Windows.

请安装mysql2 gem,不注明版本:

Please install mysql2 gem without indicating the version:

gem install mysql2

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

Which will install latest version (0.2.6 at the time of my posting this) and also provides binaries for Windows which skip the compilation step.

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

If you still want to force the compilation (because your version of MySQL differs from the one used to generate the binary gem, you will need to install RubyInstaller's DevKit from RubyInstaller website:

http://rubyinstaller.org/downloads

并遵循我们 wiki 中的 DevKit 安装说明(链接自下载页面)

And follow the DevKit installation instructions from our wiki (that is linked from the download page)

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

You will need to provide the path to both headers and libraries during the gem installation process, and adjust the MySQL installation location from the following instructions:

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 来避免路径有空格的问题,你应该避免always.

The above command uses subst to avoid issues with path with spaces, which you should avoid always.

希望这会有所帮助.

这篇关于无法在 Windows 7 上安装 MySQL2 gem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆