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

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 无法在Windows 7上安装MySQL2 gem前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在安装时收到以下错误信息,让我知道如果我需要发布更多的细节.

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

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

这是我得到的:

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

解决方法

您要安装的特定版本的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)\MysqL\MysqL Server 5.1" 
gem install MysqL2 --platform=ruby -- --with-MysqL-dir=X: --with-MysqL-lib=X:\lib\opt 
subst X: /D

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

希望这可以帮助.

原文链接:https://www.f2er.com/ruby/273699.html

猜你在找的Ruby相关文章