Installing mysql-2.9.0 gem on Windows fails due to lack of libmysql
我正在尝试在Windows Server 2003上安装Redmine 2.1.4。要使其正常工作,我需要安装
1 | gem install mysql-2.9.0.gem |
给出以下输出:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 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连接器库。我已经从http://dev.mysql.com/downloads/connector/c/下载了
我还尝试将
uby193\\bin
我还能尝试什么?
编辑
从我计算出的日志中,Ruby正在查找,意外,意外,$ RUBY_HOME \\\\ lib下的库,而不是在问题中提到的某些资源中找到的$ RUBY_HOME \\\\ bin下的库。因此,将libmysql从$ MySQL_HOME \\\\ lib移至$ RUBY_HOME \\\\ lib有所帮助,但是现在Ruby无法找到其他一些lib和标头。所以我猜,我需要使用如下选项:
1 | 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" |
也不起作用(可能是因为路径中有空格)。
尝试从http://dev.mysql.com/downloads/connector/c/使用没有安装程序版本的连接器,并从根文件夹或没有足够空间的文件夹路径中提取内容,然后尝试安装mysql gem
示例
1 | gem install mysql --platform=ruby -- --with-mysql-dir=C:/mysql-connector-c-noinstall-6.0.2-win32 |
我已经发布了带有
如果让RubyGems确定正确的平台,它将自动为您安装
安装后,它将向您显示一组说明,指示您下载MySQL Connector / C并将其DLL放在正确的位置:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 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:\ uby\\bin ====================================================================================================== Successfully installed mysql-2.9.0-x86-mingw32 1 gem installed |
如果仅需要连接到已经运行的MySQL版本,则无需下载或安装MySQL。
RubyGems和Bundler都将自动检测正确的平台并安装正确的预编译二进制文件,而无需自己编译它们。
如果您位于代理后面,请使用
希望有帮助。