简体   繁体   English

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

[英]Installing mysql-2.9.0 gem on Windows fails due to lack of libmysql

I'm trying to install Redmine 2.1.4 on Windows Server 2003. For it to work, I need to install activerecord-mysql-adapter gem, which in turn seems to rely on mysql-2.9.0.gem . 我正在尝试在Windows Server 2003上安装Redmine 2.1.4。为了工作,我需要安装activerecord-mysql-adapter gem,而这似乎依赖于mysql-2.9.0.gem I've downloaded the latter from rubygems and executed: 我从rubygems下载后者并执行:

gem install mysql-2.9.0.gem

which gives the following output: 它给出了以下输出:

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

I'm guessing, one possibility is I'm lacking MySQL C Connector library. 我猜,有一种可能性是我缺少MySQL C Connector库。 I've downloaded both mysql-connector-c-6.0.2-win32.msi and mysql-connector-c-6.0.2-win32-vs2005.msi from http://dev.mysql.com/downloads/connector/c/ , but both installers exited with: 我从http://dev.mysql.com/downloads/connector/c下载了mysql-connector-c-6.0.2-win32.msimysql-connector-c-6.0.2-win32-vs2005.msi / ,但两个安装程序都退出: 在此输入图像描述

I also tried copying C:\\Program Files\\MySQL\\MySQL Server 5.1\\lib\\debug\\libmysql.dll to C:\\Ruby193\\bin , but it also didn't solve the mysql-2.9.0.gem installation issue. 我也尝试将C:\\Program Files\\MySQL\\MySQL Server 5.1\\lib\\debug\\libmysql.dll C:\\Ruby193\\binC:\\Ruby193\\bin ,但它也没有解决mysql-2.9.0.gem的安装问题。

What else can I try? 我还能尝试什么?

EDIT 编辑

From the logs I figured, Ruby was looking for libs under, surprise, surprise, $RUBY_HOME\\lib, not $RUBY_HOME\\bin, as found in some sources mentioned in the question. 从我认为的日志中,Ruby正在寻找下的文件,惊喜,惊喜,$ RUBY_HOME \\ lib,而不是$ RUBY_HOME \\ bin,正如问题中提到的一些来源中所找到的那样。 So moving the libmysql from $MySQL_HOME\\lib to $RUBY_HOME\\lib helped a little, but now Ruby cannot find some other libs and headers. 所以将libmysql从$ MySQL_HOME \\ lib移动到$ RUBY_HOME \\ lib有点帮助,但现在Ruby找不到其他的lib和头文件了。 So I'm guessing, I need to use the an option like: 所以我猜,我需要使用如下选项:

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"

which won't work either (probably because of spaces in path). 这也不会起作用(可能是因为路径中的空格)。

Try with no installer version of connector from http://dev.mysql.com/downloads/connector/c/ and extract the content in root folder or a folder path which does not have any space for and then try to install mysql gem 尝试从http://dev.mysql.com/downloads/connector/c/没有安装程序版本的连接器,并提取根文件夹中的内容或没有任何空间的文件夹路径,然后尝试安装mysql gem

example

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

I've released mysql gem version 2.9.0 with both ruby and x86-mingw32 pre-compiled binaries. 我已经发布了带有rubyx86-mingw32预编译二进制文件的mysql gem版本2.9.0。

If you let RubyGems determine the right platform, it will automatically install x86-mingw32 platform gem for you, which will avoid the compilation process. 如果让RubyGems确定合适的平台,它将自动为您安装x86-mingw32平台gem,这将避免编译过程。

Once installed, it will show you a set of instructions indicating you to download MySQL Connector/C and placing it's DLLs in the right place: 安装完成后,它会显示一组说明,指示您下载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

There is no need to download or install MySQL if you only need to connect to an already running version of MySQL. 如果您只需要连接到已经运行的MySQL版本,则无需下载或安装MySQL。

Both RubyGems and Bundler will automatically detect the right platform and install the right pre-compiled binaries without the need to compile them on your own. RubyGems和Bundler都会自动检测正确的平台并安装正确的预编译二进制文件,而无需自己编译。

If you're behind a proxy, use --http-proxy parameter of gem install (see help) or set HTTP_PROXY environment variable. 如果您在代理后面,请使用gem install --http-proxy参数(请参阅帮助)或设置HTTP_PROXY环境变量。

Hope that helps. 希望有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM