2014-06-30 171 views
1

我已经尝试安装mysql 2 gem来开始构建我的rails应用程序。我有Rails 4.0.4和Ruby 1.9.3p545。工作了几天后,我一直得到同样的错误。我试图再次安装mysql 32位版本,以确保我的版本与正确的连接器相符,将我的libmysql.dll和libmysql.lib移动到我的ruby/bin文件夹中,并尝试了其他方式使其可以在网上找到。他们都没有为我工作。以下是我的。我将不胜感激任何帮助,让我最终安装mysql2宝石。安装mysql2 gem

PS C:\Users\pc> gem install mysql2 --no-rdoc --no-ri -- '--with-mysql-lib="C:\Program Files\MySQL\ 
.6\lib\" --with-mysql-include="C:\Program Files\MySQL\MySQL Server 5.6\include\"' 
Temporarily enhancing PATH to include DevKit... 
Building native extensions with: '--with-mysql-lib=C:\Program Files\MySQL\MySQL Server 5.6\lib" --with-mys 
Program Files\MySQL\MySQL Server 5.6\include"' 
This could take a while... 
ERROR: Error installing mysql2: 
     ERROR: Failed to build gem native extension. 

    C:/Ruby193/bin/ruby.exe extconf.rb --with-mysql-lib=C:\Program Files\MySQL\MySQL Server 5.6\lib" --wit 
e=C:\Program Files\MySQL\MySQL Server 5.6\include" 
checking for ruby/thread.h... no 
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. 

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:/Ruby193/bin/ruby 
     --with-mysql-dir 
     --without-mysql-dir 
     --with-mysql-include 
     --without-mysql-include=${mysql-dir}/include 
     --with-mysql-lib=${mysql-dir}/lib 
     --with-mysql-config 
     --without-mysql-config 
     --with-mysql-dir 
     --without-mysql-dir 
     --with-mysql-include 
     --without-mysql-include=${mysql-dir}/include 
     --with-mysql-lib=${mysql-dir}/lib 
     --with-mysqlclientlib 
     --without-mysqlclientlib 
     --with-mlib 
     --without-mlib 
     --with-mysqlclientlib 
     --without-mysqlclientlib 
     --with-zlib 
     --without-zlib 
     --with-mysqlclientlib 
     --without-mysqlclientlib 
     --with-socketlib 
     --without-socketlib 
     --with-mysqlclientlib 
     --without-mysqlclientlib 
     --with-nsllib 
     --without-nsllib 
     --with-mysqlclientlib 
     --without-mysqlclientlib 
     --with-mygcclib 
     --without-mygcclib 
     --with-mysqlclientlib 
     --without-mysqlclientlib 

extconf failed, exit code 1 

Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql2-0.3.16 for inspection. 
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/extensions/x86-mingw32/1.9.1/mysql2-0.3.16/gem_make.out 
+1

你需要一些MySQL的开发库,我不知道它是如何工作的窗口,虽然,检查这一点,可以帮助HTTP://计算器。 com/questions/4115126/ruby​​-gem-mysql2-install-failing –

回答

2

我们写了一篇关于如何做一个教程这个here

-

有几个问题与你在做什么:

  1. 你不能有任何路径中的空格
  2. 您需要包含最新版本的MYSQL C-Connector

这为我们工作:

  • 下载最新32位版本的MYSQL C-Connector
  • 安装到一个路径没有空格
  • 使用以下命令:

    gem install mysql2 --platform=ruby -- ‘--with-mysql-dir=”C:\mysql-connector-path”’

这应该正确安装

+0

我试过了。不幸的是,这导致了对大量不同项目的未定义引用。我不太明白为什么会这样。最后,它说,“失败,退出代码2”。问题仍未解决。 – user3694391

+0

我已经完成了你所说的。但是,运行安装程序不会提供必须解压缩的zip文件。它只是直接下载文件。然后,当我在终端中传递正确的命令时,我收到了大量未定义的引用,如'mysql_error @ 4','mysql_init @ 4','mysql_num_rows @ 4'。请帮帮我。我无法弄清楚这里有什么问题。 – user3694391

+2

它终于奏效了!我必须确保将新连接器中的新libmysql.dll文件复制到我的ruby/bin和lib文件夹中。 :) – user3694391