[英]Installing mysql ruby gem in windows fails using ruby 2.0.0
Using chocolately I have installed ruby and ruby.devkit 使用巧克力我已经安装了ruby和ruby.devkit
cinst ruby
cinst ruby.devkit
I then followed the instructions on the github wiki and tested the devkit as so detailed in point 5 然后,我按照github Wiki上的说明进行了测试,并测试了第5点中详细介绍的devkit
gem install json --platform=ruby
ruby -rubygems -e "require 'json'; puts JSON.load('[42]').inspect"
This worked ok so I assume my devkit installation was correct. 这项工作正常,所以我认为我的devkit安装正确。 However when I try to install mysql gem like so 但是当我尝试像这样安装mysql gem时
gem install mysql --platform=ruby -- --with-mysql-dir=C:/mysql-connector-c-noinstall-6.0.2-win32
I get the following error 我收到以下错误
This could take a while...
ERROR: Error installing mysql:
ERROR: Failed to build gem native extension.
C:/ruby200/bin/ruby.exe extconf.rb --with-mysql-dir=C:/mysql-connector-c-noinstall-6.0.2-win32
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:/ruby200/bin/ruby
--with-mysql-dir
--with-mysql-include
--without-mysql-include=${mysql-dir}/include
--with-mysql-lib=${mysql-dir}/
--with-libmysqllib
--without-libmysqllib
Gem files will remain installed in C:/ruby200/lib/ruby/gems/2.0.0/gems/mysql-2.9.1 for inspection.
Results logged to C:/ruby200/lib/ruby/gems/2.0.0/gems/mysql-2.9.1/ext/mysql_api/gem_make.out
I've got all the paths correct and I was following this tutorial . 我的所有路径都正确无误,我正在遵循本教程 。 The log file isn't much help to me but here it is. 日志文件对我没有太大帮助,但是就在这里。
have_library: checking for main() in -llibmysql... -------------------- no
"gcc -o conftest.exe -IC:/ruby200/include/ruby-2.0.0/i386-mingw32 -IC:/ruby200/include/ruby-2.0.0/ruby/backward -IC:/ruby200/include/ruby-2.0.0 -I. -IC:/mysql-connector-c-noinstall-6.0.2-win32/include -DFD_SETSIZE=2048 -D_WIN32_WINNT=0x0501 -D_FILE_OFFSET_BITS=64 -O3 -fno-omit-frame-pointer -fno-fast-math -g -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration conftest.c -L. -LC:/ruby200/lib -LC:\mysql-connector-c-noinstall-6.0.2-win32\lib\libmysql.dll -LC:/mysql-connector-c-noinstall-6.0.2-win32/ -L. -lmsvcrt-ruby200 -lshell32 -lws2_32 -limagehlp -lshlwapi "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: #include <winsock2.h>
4: #include <windows.h>
5: int main(int argc, char **argv)
6: {
7: return 0;
8: }
/* end */
Related questions 相关问题
Installing mysql-2.9.0 gem on Windows fails due to lack of libmysql Has the exact same error but I'm already doing the accepted answer and still getting the error 由于缺少libmysql,在Windows上安装mysql-2.9.0 gem失败。具有完全相同的错误,但我已经在接受错误的答案了,但仍然收到错误
this answer seems to suggest that I shouldn't bother trying to build the gem and just use the binary version https://stackoverflow.com/a/13613036/799628 so maybe I'll just do that... 这个答案似乎表明我不应该费心尝试构建gem并仅使用二进制版本https://stackoverflow.com/a/13613036/799628,所以也许我会这样做。
Note: I ended up using the mysql2
gem instead which has enough functionality for what I'm needing. 注意:我最终使用了mysql2
gem,它具有足够的功能来满足我的需求。
I also faced the same problem now. 我现在也面临着同样的问题。 But fixed for ruby 2.0.0 但固定为Ruby 2.0.0
Download mysql connector for c from hear http://dev.mysql.com/downloads/connector/c/ extract to a directory and then 从听到的http://dev.mysql.com/downloads/connector/c/解压缩到目录中下载mysql的c连接器,然后
gem install mysql2 --platform=ruby -- --with-mysql-dir=C:/mysql-connector-c-noinstall-6.0.2-win32
为了使mysql
gem正常工作,需要以下命令进行安装
gem install mysql --platform=ruby -- --with-opt-dir=C:/mysql-connector-c-noinstall-6.0.2-win32
Another approach 另一种方法
Install according to your CPU either one or another: 根据您的CPU安装一个或另一个:
http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-6.1.3-win32.msi http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-6.1.3-winx64.msi http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-6.1.3-win32.msi http://dev.mysql.com/get/Downloads/Connector-C/mysql -连接器-c-6.1.3-winx64.msi
Prepare a drive pointing to where you have installed C files: 准备一个指向您已安装C文件的驱动器:
subst x: "C:\Program Files\MySQL\MySQL Connector C 6.1"
or 要么
subst x: "C:\Program Files (x86)\MySQL\MySQL Connector C 6.1"
Now run gem install, remember that you must have installed Devkit and added Ruby\\bin and devkit\\bin path in your environment PATH: 现在运行gem install,请记住您必须已安装Devkit并在环境PATH中添加了Ruby \\ bin和devkit \\ bin路径:
C:\Ruby\bin>gem install mysql --platform=ruby -- --with-opt-dir=x:
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-opt-dir=x:'
This could take a while...
Successfully installed mysql-2.9.1
Parsing documentation for mysql-2.9.1
Installing ri documentation for mysql-2.9.1
Done installing documentation for mysql after 1 seconds
1 gem installed
Delete the temp drive 删除临时驱动器
subst x: /d
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.