【问题标题】:install Mysql2 -v '0.3.14' for rails 4 error安装 Mysql2 -v '0.3.14' for rails 4 错误
【发布时间】:2014-03-07 18:14:38
【问题描述】:

我需要一些帮助来在 windows 7

上为 rails 4 安装 Mysql2 -v '0.3.14'

总是在运行命令 `gem install mysql2 -v '0.3.14'

我总是得到错误

c:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb
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:/RailsInstaller/Ruby1.9.3/bin/ruby
    --with-mysql-dir
    --without-mysql-dir
    --with-mysql-include
    --without-mysql-include=${mysql-dir}/include
    --with-mysql-lib
    --without-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
    --without-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

注意:当我安装 mysql2 -v 0.2.6 时,它安装得很好 但我不知道为什么 v 0.3.14 会出现此错误

我如何解决这个问题??

当我尝试使用命令安装它时

gem install mysql --platform=ruby -- --with-mysql-include=C:\mysql-connector-c-noinstall-6.0.2-win32\include --with-mysql-lib=C:\ mysql-connector-c-noinstall-6.0.2-win32\lib

我收到了错误

c:/RailsInstaller/Ruby1.9.3/bin/ruby.exe extconf.rb --with-mysql-include=c:mysql-connector-c-noinstall-6.0.2-win32include --with-mysql-lib=mysql-connector-c-noinstall-6.0.2-win32lib
checking for main() in -llibmysql... 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:/RailsInstaller/Ruby1.9.3/bin/ruby
    --with-mysql-dir
    --without-mysql-dir
    --with-mysql-include=${mysql-dir}/include
    --with-mysql-lib=${mysql-dir}/lib
    --with-libmysqllib
    --without-libmysqllib

【问题讨论】:

  • ????????????????????????????????????
  • 在linux上通过安装mysql客户端“libmysqlclient-dev”的开发库解决了这个问题。你认为你可以在 Windows 上做到这一点吗?

标签: mysql2


【解决方案1】:

1-首先从这个页面下载mysql-connector-c-6.1.3-win32

http://dev.mysql.com/downloads/connector/c/

注意:下载 ZIP 存档文件

2-解压缩c盘中的文件,像这样
C:\mysql-连接器

3-运行命令

$ gem install mysql2 -v 0.3.14 -- '--with-mysql-dir="C:\mysql-connector"'

它应该会给你结果

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
Successfully installed mysql2-0.3.14
1 gem installed
Installing ri documentation for mysql2-0.3.14...
Installing RDoc documentation for mysql2-0.3.14... 

4- 如果你得到错误mysql2 gemcompiled for wrong mysql client library

您需要从连接器文件中获取 dll 文件 你会在路径中找到它 C:\mysql-connector\lib\libmysql.dll

然后将其复制到您的 Ruby bin 文件夹中 你会发现它也许是路径 C:\Ruby200\bin

【讨论】:

    【解决方案2】:

    libmysql.dll 是 MySQL2 正在寻找的。该文件位于 MySQL C 连接器的 lib 文件夹中。您可以从“http://dev.mysql.com/downloads/connector/c/”MSI 或 ZiP 下载连接器,但请确保获得相同的 32 位或 64 位架构。否则在安装 mySQL2 gem 时会出错,提示“有符号和无符号整数表达式之间的比较”和一大堆“未定义引用”

    下载并安装连接器后(如果您下载了 MSI),打开“MySQL Connector C 6.1”,其中 6.1 是版本号 - 文件夹位于 Program Files(如果您下载 32 位版本,则为 Program Files (x86))。转到“lib”文件夹并复制“libmysql.dll”和“libmysql.lib”并将它们粘贴到 mysql 服务器目录的“lib”文件夹中,例如“C:\MySQL\MySQL_Server_5.6\lib”

    然后'gem install mysql -v [版本号] --with-mysql-dir="C:\MySQL\MySQL_Server_5.6\"'

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-15
      • 2017-01-28
      • 1970-01-01
      • 1970-01-01
      • 2012-04-04
      • 2015-11-14
      • 2012-12-21
      • 2011-08-12
      相关资源
      最近更新 更多