mysql - Ruby on Rails 安装问题 (Windows)

标签 mysql ruby-on-rails ruby windows

我从 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 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"'
    

关于mysql - Ruby on Rails 安装问题 (Windows),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19946228/

相关文章:

PHP Mysql 空白日期字段值提交

ruby-on-rails - 在服务器上没有互联网访问权限的 Capistrano 部署

ruby-on-rails - Ruby net/ssh 与特定主机挂起

ruby-on-rails - end_of_week 返回不同日期

ruby - 如何从代码中引用 Docker 卷?

c - 在 ruby​​ 上调用 c 函数时出现段错误

.net - MySqlConnection 与框架 3.5

javascript - 从数据库获取文本值而不换行以使用它的javascript变量

mysql - 如何在按下按钮后动态更新 Kivy 标签

ruby-on-rails - 设计自定义路线滑坡