1

私は Ruby でもう少し遊びたいと思っており、現在 sinatra を把握しているようですが、リレーショナル データベースからデータを取得したいと考えています。私はテストアプリに Mysql を使用する傾向があり、宝石をインストールしようとしましたが、依存しているネイティブの do_mysql 宝石をコンパイルしようとすると例外が発生し続けます。

私はネイティブ拡張機能をインストールしており、JSON gem で問題なく動作しました。do_mysql が現在 Windows でサポートされていないことをどこかで読んだことを覚えているので、これがまだ当てはまるかどうか疑問に思っていました。

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
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 がシステム PATH に追加されました。

4

2 に答える 2

3

DataMapper と DataObjects (DB に接続する下位層)、Windows で動作します。

ただし、do_mysql 0.10.7 には、x86-mingw32プラットフォーム用のプリコンパイル済みバイナリが欠落しているようです。

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

コンピュータにインストールされている MySQL のバージョンに依存しない MySQL Connector/C インターフェイスを使用して do_mysql を自分でコンパイルできます。

インストール手順については、次のブログ記事をご覧ください。

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

手順はmysqlgem 用ですが、変更するとうまくいくdo_mysqlはずです (MySQL 固有のコード例を除く)。

それが役立つことを願っています。

于 2011-11-17T17:38:30.387 に答える
0

ルイスの答えをリンク解除するには、次のようにします。

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」ディレクトリの短いバージョンです。

于 2016-06-07T03:50:28.530 に答える