2011-11-17 48 views
1

我想用Ruby來玩更多,目前似乎掌握了sinatra,但現在也想從關係數據庫中獲取數據。我傾向於將Mysql用於測試應用程序,並嘗試安裝這些gem,但是當它試圖編譯它所依賴的原生do_mysql gem時,我一直收到異常。Datamapper的dm_mysql_adapter gem是否支持Windows?

我確實已經安裝了本機擴展,並且它們對於JSON gem來說工作得很好,我記得之前在某個地方讀到了do_mysql目前不支持Windows,所以只是想知道這是否仍然如此。

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 
l.c 
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的:

在Windows 7上使用Ruby 1.9.2

這裏是例外櫃面它有助於(通過安裝紅寶石+原生擴展安裝)已被添加到系統PATH。

回答

3

DataMapper和DataObjects(連接到數據庫的較低層)在Windows上工作。

然而,似乎do_mysql 0.10.7缺少預編譯的二進制爲x86-mingw32平臺:

http://rubygems.org/gems/do_mysql/versions

可以do_mysql自己使用MySQL連接器/ C接口,它是獨立的MySQL版本編譯你已經安裝在你的電腦中。

請看看這個博客帖子提供的安裝說明:

http://blog.mmediasys.com/2011/07/07/installing-mysql-on-windows-7-x64-and-using-ruby-with-it/

的說明適用於mysql寶石,但將其更改爲do_mysql應該工作(除示例代碼是MySQL的具體。

希望幫助

+0

工作過,我學到了新東西。非常感謝您花時間幫忙!有一件事引起了我的興趣,當時我正在命令行中指定MySQL目錄,我試圖使用相對路徑,並導致錯誤,使其絕對修復它(我知道你展示的例子是絕對的,但沒有知道這是一個要求),只是將其他人趕走。 – Grofit

+0

太棒了,會更新說明提及,也避免與空間路徑! :) –

0

到delinkify路易斯的回答,它看起來是這樣的:

寶石安裝do_mysql --platform =紅寶石 - --with MySQL的-DIR = 「C:/PROGRA~1/MySQL/MYSQLS~1.7/」

其中 「的MySQL-DIR」 路徑是在x64系統的「C:\ Program Files」中的「MySQL Server 5.7」目錄的簡短版本。