Windows上是否支持Datamapper的dm_mysql_adapter gem?
我想用Ruby发挥更多,目前似乎掌握了sinatra,但现在也希望从关系数据库中获取数据。 我倾向于将Mysql用于测试应用程序并尝试安装gems,但是当它尝试编译它所依赖的本机do_mysql gem时,我一直遇到exception。
我确实已经安装了原生扩展,并且它们对JSON gem工作得很好,我记得有一段时间在某处读取当前不支持windows的do_mysql,所以只是想知道是否仍然如此。
在Windows 7上使用ruby 1.9.2(通过ruby安装程序+本机扩展安装)
这是例外,它有助于:
C:\dump\ruby\DataMapperTest\gems>gem install dm-mysql-adapter-1.2.0.gem Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... ERROR: Error installing dm-mysql-adapter-1.2.0.gem: ERROR: Failed to build gem native extension. C:/Tools/Ruby192/bin/ruby.exe extconf.rb checking for my_global.h... no checking for mysql.h... no checking for main() in -llibmysql... no checking for mysql_query() in mysql.h... no checking for mysql_ssl_set() in mysql.h... no checking for localtime_r()... no checking for gmtime_r()... no checking for mysql.h... no checking for MYSQL_TYPE_STRING in mysql.h... no checking for MYSQL_TYPE_BIT in mysql.h... no checking for MYSQL_TYPE_NEWDECIMAL in mysql.h... no checking for mysql_query() in mysql.h... no checking for mysql_ssl_set() in mysql.h... no checking for mysql_sqlstate() in mysql.h... no checking for mysql_get_ssl_cipher() in mysql.h... no checking for mysql_set_character_set() in mysql.h... no checking for mysql_get_server_version() in mysql.h... no checking for MYSQL_FIELD.charsetnr in mysql.h... no creating Makefile make C:/Tools/Ruby192/bin/ruby -e "puts 'EXPORTS', 'Init_do_mysql'" > do_mysql-i386- mingw32.def gcc -I. -IC:/Tools/Ruby192/include/ruby-1.9.1/i386-mingw32 -I/C/Tools/Ruby192/in clude/ruby-1.9.1/ruby/backward -I/C/Tools/Ruby192/include/ruby-1.9.1 -I. -O3 - g -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wall -o do_common.o -c do_com mon.c gcc -I. -IC:/Tools/Ruby192/include/ruby-1.9.1/i386-mingw32 -I/C/Tools/Ruby192/in clude/ruby-1.9.1/ruby/backward -I/C/Tools/Ruby192/include/ruby-1.9.1 -I. -O3 - g -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wall -o do_mysql.o -c do_mysq lc do_mysql.c:5:19: fatal error: mysql.h: No such file or directory compilation terminated. make: *** [do_mysql.o] Error 1 Gem files will remain installed in C:/Tools/Ruby192/lib/ruby/gems/1.9.1/gems/do_ mysql-0.10.7 for inspection. Results logged to C:/Tools/Ruby192/lib/ruby/gems/1.9.1/gems/do_mysql-0.10.7/ext/ do_mysql/gem_make.out C:\dump\ruby\DataMapperTest\gems>
安装并配置了Mysql 5.5社区版,并将Mysql添加到系统PATH中。
DataMapper和DataObjects(连接到DB的下层)可以在Windows上运行。
但是,似乎do_mysql 0.10.7缺少x86-mingw32
平台的预编译二进制文件:
http://rubygems.org/gems/do_mysql/versions
您可以使用MySQL Connector / C接口自行编译do_mysql,该接口独立于您在计算机中安装的MySQL版本。
请查看此博客文章,其中提供了安装说明:
http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/
这些指令适用于mysql
gem,但将其更改为do_mysql
应该可以工作(除了特定于MySQL的示例代码)。
希望有所帮助。
将路易斯的答案脱钩,它看起来像这样:
gem install do_mysql –platform = ruby – –with-mysql-dir =“C:/PROGRA~1/MySQL/MYSQLS~1.7/”
其中“mysql-dir”路径是x64系统上“C:\ Program Files”中“MySQL Server 5.7”目录的简短版本。