【问题标题】:Ruby on Rails installation issue (Windows)Ruby on Rails 安装问题 (Windows)
【发布时间】:2013-11-13 05:44:04
【问题描述】:

我从 RuyInstaller 安装了 Ruby 2.0.0 和 DevKit。创建新项目时出现错误消息:

rails new testtest -d mysql

..... a lot of output here ........

Installing mysql2 (0.3.14)
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    C:/Ruby200/bin/ruby.exe extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... 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.

如何安装依赖项以使这个 gem 没有任何错误?

【问题讨论】:

标签: mysql ruby-on-rails ruby windows


【解决方案1】:

您需要 MySQL 32 位(或 MySQL Connector C)在 Windows 上编译 mysql2 gem 编译(即使您使用的是 64 位版本的操作系统)。

按照以下步骤操作:

  1. 下载 MySQL Server 32 位 .zip 文件(或者MySQL Connector C 也可以)
  2. libmysql.dll 复制到%RUBY_HOME%\bin(或简单地将MySQL 32 位lib 目录添加到PATH)
  3. 使用--with-mysql-lib--with-mysql-include 选项安装mysql2 gem

    gem install mysql2 -- '--with-mysql-lib="c:\path\to\32-bit-MySQL-Server\lib\opt" --with-mysql-include="c:\\path\to\32-bit-MySQL-Server\include"'
    

【讨论】:

  • 谢谢。真的很简单:gem install mysql2 -v 0.3.14 --platform=ruby -- --with-mysql-dir=C:\mysql
【解决方案2】:

这是我的故事。尝试使用 devkit 在 Windows 7 上安装 mysql2 gem。 首先,您需要安装连接器库和头文件。 不要使用默认文件夹“Program Files”,gem 无法包含带空格的文件夹。 我已经通过 subst X:\ "C:\Program File\Mysql Connector 6 C\" 替换了连接器文件夹 然后使用以下cmd: gem install mysql2 -- --with-mysql-dir=X:\ 然后意识到我正在使用带有 32 位 ruby​​ 的 64 位连接器库。 重新安装连接器。 然后gem就安装成功了。 但是运行失败,抱怨缺少mysql dll。所以,我把 libmysql.dll 和 *.lib 放到了 ruby​​\bin 文件夹中。毕竟这可以使用mysql2 gem。

【讨论】:

    猜你喜欢
    • 2011-05-30
    • 2019-08-31
    • 1970-01-01
    • 1970-01-01
    • 2013-10-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-26
    相关资源
    最近更新 更多