【问题标题】:Can't Install MySQL2 0.3.16 gem on Ruby无法在 Ruby 上安装 MySQL2 0.3.16 gem
【发布时间】:2014-07-09 08:44:16
【问题描述】:

我在 Ruby 上安装 mysql2 gem 时遇到了一堆问题,我尝试了很多指南,但似乎没有任何工作...这是我尝试安装它时出现的错误,没有任何额外的命令.

C:\Users\Julián>gem install mysql2 --no-rdoc --no-ri
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.

C:/Ruby200-x64/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.

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:/Ruby200-x64/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}/
    --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}/
    --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:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql
2-0.3.16 for inspection.
Results logged to C:/Ruby200-x64/lib/ruby/gems/2.0.0/extensions/x64-mingw32/2.0.
0/mysql2-0.3.16/gem_make.out

我真的很难过,我试图在这里找到解决方案,但找不到任何东西。我尝试安装 MySQL 连接器并设置 with-mysql-lib 命令。请帮忙!

【问题讨论】:

标签: mysql ruby-on-rails ruby gem


【解决方案1】:

由于您使用的是 Windows,因此您需要考虑必须安装 MYSQL C-Connector 头文件才能使其工作

我们写了一个tutorial about this here

--

您需要使用以下步骤:

  1. 安装MYSQL C-Connector 文件(路径中不包含任何空格)
  2. 再次安装 MYSQL2 gem(使用正确的路径引用)
  3. lbmysql.dll 复制到您的ruby/bin 文件夹

首先,您需要下载 MYSQL C-Connector 文件:

必须是 32 位 C-Connector

将其安装到没有空格的路径后,您可以再次使用mysql2 安装命令,并带有配置选项:

gem install mysql2 --platform=ruby -- '--with-mysql-dir="C:\mysql-connector-path"'

之后,您可以将libmysql.dll 从您的mysql 文件传输到您的ruby/bin 目录:

【讨论】:

  • 谢谢你,但是,在你的网站上,你的命令 gem install mysql2 —platform=ruby — '—with-mysql-dir=”C:\mysql-connector-path”' 的漂亮字体一团糟粘贴时启动...没什么大不了的,+1 ..再次感谢。
  • 如何指定要安装的版本? --version 0.3.16 什么都不做。
【解决方案2】:

在终端中。首先执行“locate mysql_config”,然后将以下命令中的路径替换为该文件所在的位置。

gem install mysql2 --no-rdoc --no-ri --with-mysql-config=路径

【讨论】:

    猜你喜欢
    • 2020-12-08
    • 1970-01-01
    • 2021-12-23
    • 2015-04-25
    • 2013-10-01
    • 2011-08-16
    • 2012-12-20
    相关资源
    最近更新 更多