我从 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 位版本的操作系统)。
请按照以下步骤操作:
- 下载 MySQL Server 32 位 .zip 文件(或者 MySQL Connector C 也可以)
- 将
libmysql.dll
复制到%RUBY_HOME%\bin
(或者简单地将 MySQL 32 位lib
目录添加到 PATH) 使用
--with-mysql-lib
和--with-mysql-include
选项安装 mysql2 gemgem 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/