问题描述
安装时出现以下错误消息,请告诉我是否需要发布更多详细信息。
我按照以下指示操作:
我使用ruby 1.9.2p136 (2010-12-25)[i386-mingw32]。
以下是我得到的结果:
E:\ work_desk\trunk> gem install mysql2 -v 0.2.4
临时增强PATH以包含DevKit ...
构建本机扩展。这可能需要一段时间...
错误:安装mysql2时出错:
错误:无法构建gem本机扩展。
C:/Ruby192/bin/ruby.exe extconf.rb
检查rb_thread_blocking_region()...是
检查main()in -llibmysql ...否
*** extconf.rb失败***
由于某些原因无法创建Makefile,可能缺少
必需的库和/或头文件。查看mkmf.log文件以获取更多
的详细信息。您可能需要配置选项。
提供的配置选项:
--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文件将保持安装在C:/ Ruby192 / lib /红宝石/宝石/ 1.9.1 /宝石/ mysql2-0。
2.4进行检查。
记录到C的结果:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.4/ext/mysql2/ge
m_make.out
您试图安装的特定版本的mysql2 gem不仅缺少Windows的二进制文件,但在Windows上有问题。
请安装mysql2 gem而不指出版本:
gem install mysql2
将安装最新版本(0.2.6在发布这篇文章时),还提供了Windows的二进制文件,它可以跳过编译步骤。
如果仍然要强制编译(因为您的MySQL版本与用于生成二进制gem的版本不同,您需要从RubyInstaller网站安装RubyInstaller的DevKit:
然后按照 DevKit安装说明(通过下载页面链接)
您需要在gem安装过程中提供标题和库的路径,并根据以下说明调整MySQL安装位置:
subst X:C:\ Program Files(x86)\MySQL\MySQL Server 5.1
gem install mysql2 --platform = ruby - - --with-mysql-dir = X:--with-mysql-lib = X:\lib\opt
subst X:/ D
上面的命令使用 subst
来避免带空格的路径问题,您应该避免使用 always 。
希望这有助于您。
I am getting the following error message while installing, let me know if I need to post more details.
I followed instructions from the following location:https://github.com/oneclick/rubyinstaller/wiki/Development-Kit
I am using ruby 1.9.2p136 (2010-12-25) [i386-mingw32].
Here is what I get:
E:\work_desk\trunk>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
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.
Please install mysql2 gem without indicating the version:
gem install mysql2
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.
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
And follow the DevKit installation instructions from our wiki (that is linked from the download page)
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)\MySQL\MySQL Server 5.1"
gem install mysql2 --platform=ruby -- --with-mysql-dir=X: --with-mysql-lib=X:\lib\opt
subst X: /D
The above command uses subst
to avoid issues with path with spaces, which you should avoid always.
Hope this helps.
这篇关于无法在Windows 7上安装MySQL2 gem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!