我尝试在带有gem的rails上的ruby上安装mysql2但是,我收到了这个错误:
我使用的是gem 2.4.2和ruby 2.1.4。有人知道如何解决它吗?
gem.bat : ERROR: Error installing mysql2:
Em linha:1 caractere:4
+ gem <<<< install mysql2
+ CategoryInfo : NotSpecified: (ERROR: Error installing mysql2::String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
ERROR: Failed to build gem native extension.
C:/Ruby21/bin/ruby.exe -r ./siteconf20141107-7440-10fbirr.rb 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... *** 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.
答案 0 :(得分:0)
mysql2
gem's GitHub page暗示了这一点:
但是,我会切换到基于Linux的虚拟机。这有几个原因:窗
首先,确保安装了DevKit (http://rubyinstaller.org/downloads/)及其变量由 运行devkit \ devktvars.bat。
接下来,您需要一个MySQL库来链接。如果你有MySQL 加载到您的开发机器上,您可以使用它。如果没有,你会的 需要从服务器复制MySQL目录,否则 获取MySQL C连接器的副本: http://dev.mysql.com/downloads/connector/c/
如果您正在使用连接器,我建议您只获取.zip文件 并在方便的地方解压缩。
现在你可以安装mysql2了。您必须使用
--with-mysql-dir
选项 告诉gem你的MySQL库文件在哪里。例如,如果你 将连接器解压缩到c:\mysql-connector-c-6.1.1-win32
像这样安装宝石:gem install mysql2 -- --with-mysql-dir=c:\mysql-connector-c-6.1.1-win32
最后,您必须从MySQL或MySQL的lib子目录中复制
libmysql.dll
连接器目录到ruby \ bin目录中。在上面 例如,libmysql.dll将位于 c:\ mysql-connector-c-6.1.1-win32 \ lib。