Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 由于缺少libmysql,在Windows上安装mysql-2.9.0 gem失败_Ruby_Mysql Connector - Fatal编程技术网

Ruby 由于缺少libmysql,在Windows上安装mysql-2.9.0 gem失败

Ruby 由于缺少libmysql,在Windows上安装mysql-2.9.0 gem失败,ruby,mysql-connector,Ruby,Mysql Connector,我正在尝试在Windows Server 2003上安装Redmine 2.1.4。为了让它正常工作,我需要安装activerecordmysql适配器gem,它似乎反过来依赖于mysql-2.9.0.gem。我已从下载了后者并执行: gem install mysql-2.9.0.gem 这将提供以下输出: C:\>gem install mysql-2.9.0.gem Temporarily enhancing PATH to include DevKit... Building n

我正在尝试在Windows Server 2003上安装Redmine 2.1.4。为了让它正常工作,我需要安装
activerecordmysql适配器
gem,它似乎反过来依赖于
mysql-2.9.0.gem
。我已从下载了后者并执行:

gem install mysql-2.9.0.gem
这将提供以下输出:

C:\>gem install mysql-2.9.0.gem
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing mysql-2.9.0.gem:
        ERROR: Failed to build gem native extension.

        C:/Ruby193/bin/ruby.exe extconf.rb
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:/Ruby193/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-libmysqllib
        --without-libmysqllib


Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql-2.9.0 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/mysql-2.9.0/ext/mysql_api/gem_make.out
我猜,一种可能是我缺少MySQL C连接器库。我已从下载了mysql-connector-c-6.0.2-win32.msi和mysql-connector-c-6.0.2-win32-vs2005.msi,但两个安装程序均已退出:

我还尝试将
C:\Program Files\MySQL\MySQL Server 5.1\lib\debug\libmysql.dll
复制到
C:\Ruby193\bin
,但它也没有解决MySQL-2.9.0.gem的安装问题

我还能试什么

编辑

从我的日志中可以看出,Ruby是在$Ruby\u HOME\lib下寻找lib的,而不是$Ruby\u HOME\bin,正如在问题中提到的一些来源中所发现的那样。因此,将libmysql从$MySQL\u HOME\lib移动到$RUBY\u HOME\lib有点帮助,但现在RUBY找不到其他lib和头。所以我猜,我需要使用如下选项:

C:\>gem install mysql-2.9.0.gem --platform=ruby --with-opt-lib="C:/Program Files/MySQL/MySQL Server 5.1/lib" --with-opt-include="C:/Program Files/MySQL/MySQL Server 5.1/include"

这也不起作用(可能是因为路径中有空格)

尝试从没有安装程序版本的连接器中提取根文件夹或没有空间的文件夹路径中的内容,然后尝试安装mysql gem

示例

gem install mysql --platform=ruby -- --with-mysql-dir=C:/mysql-connector-c-noinstall-6.0.2-win32

我发布了mysql gem 2.9.0版,其中包含
ruby
x86-mingw32
预编译的二进制文件

如果让RubyGems确定正确的平台,它将自动为您安装
x86-mingw32
platform gem,这将避免编译过程

安装后,它将向您显示一组说明,指示您下载MySQL Connector/C并将其DLL放置在正确的位置:

C:\Users\Luis>gem install mysql
Fetching: mysql-2.9.0-x86-mingw32.gem (100%)

======================================================================================================

  You've installed the binary version of mysql.
  It was built using MySQL Connector/C version 6.0.2.
  It's recommended to use the exact same version to avoid potential issues.

  At the time of building this gem, the necessary DLL files where available
  in the following URL:

  http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick

  You can put the lib\libmysql.dll available in this package to your Ruby bin directory.
  E.g. C:\Ruby\bin

======================================================================================================

Successfully installed mysql-2.9.0-x86-mingw32
1 gem installed
如果只需要连接到已经运行的MySQL版本,则无需下载或安装MySQL

RubyGems和Bundler都将自动检测正确的平台并安装正确的预编译二进制文件,而无需自己编译它们

如果您在代理后面,请使用
gem install
--http proxy
参数(请参阅帮助)或设置
http\u proxy
环境变量


希望有帮助。

mkmf.log怎么说?在我的经验中,您可以使用gem安装mysql,也可以使用mysql2。我不知道这些日志-谢谢-编辑了我的问题。除了从提供的链接下载连接器外,该命令行还为我提供了窍门:gem安装mysql--platform=ruby--with mysql lib=c:\mysql\u connector\lib--with mysql include=c:\mysql\u connector\include(我重命名了提取归档内容的目录的名称)我刚刚使用MySQL Connector 6.1.3成功安装了它,并使用以下命令:gem install mysql2--platform=ruby--with MySQL dir=c:/Connector-6.1.3