3

MySQL で RubyOnRails 開発環境をセットアップしようとしています。XAMPP がインストールされているので、XAMPP の MySQL インストールを使用することにしました (したがって、XAMPP dev パッケージをインストールしました)。

今、mysql2 gem をインストールしようとしていますが、次のエラーが発生しました。

gem install mysql2 --version 0.2.7 -- --with-mysql-dir=/Applications/XAMPP/xamppfiles/ --with-mysql-lib=/Applications/XAMPP/xamppfiles/lib/mysql/ –with-mysql-include=/Applications/XAMPP/xamppfiles/include/mysql/ --with-mysql-config=/Applications/XAMPP/xamppfiles/bin/mysql_config 
Error loading RubyGems plugin "/Library/Ruby/Gems/1.8/gems/yard-0.6.3/lib/rubygems_plugin.rb": undefined method `overwrite_accessor' for Gem::Specification:Class (NoMethodError)
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.

  /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb --with-mysql-dir=/Applications/XAMPP/xamppfiles/ --with-mysql-lib=/Applications/XAMPP/xamppfiles/lib/mysql/ –with-mysql-include=/Applications/XAMPP/xamppfiles/include/mysql/ --with-mysql-config=/Applications/XAMPP/xamppfiles/bin/mysql_config
checking for rb_thread_blocking_region()... no
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
creating Makefile

make
gcc -I. -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin10.0 -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/Applications/XAMPP/xamppfiles/include/mysql  -I/Applications/XAMPP/xamppfiles/include -L/Applications/XAMPP/xamppfiles/lib -mmacosx-version-min=10.4 -arch i386 -arch ppc   -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT  -DDONT_DECLARE_CXA_PURE_VIRTUAL -fno-common -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE  -fno-common  -pipe -fno-common  -Wall -funroll-loops  -c client.c
gcc -I. -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin10.0 -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/Applications/XAMPP/xamppfiles/include/mysql  -I/Applications/XAMPP/xamppfiles/include -L/Applications/XAMPP/xamppfiles/lib -mmacosx-version-min=10.4 -arch i386 -arch ppc   -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT  -DDONT_DECLARE_CXA_PURE_VIRTUAL -fno-common -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE  -fno-common  -pipe -fno-common  -Wall -funroll-loops  -c mysql2_ext.c
./client.h:20: warning: ‘rb_thread_blocking_region’ defined but not used
./client.h:20: warning: ‘rb_thread_blocking_region’ defined but not used
./client.h:20: warning: ‘rb_thread_blocking_region’ defined but not used
gcc -I. -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin10.0 -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -I/Applications/XAMPP/xamppfiles/include/mysql  -I/Applications/XAMPP/xamppfiles/include -L/Applications/XAMPP/xamppfiles/lib -mmacosx-version-min=10.4 -arch i386 -arch ppc   -D_P1003_1B_VISIBLE -DSIGNAL_WITH_VIO_CLOSE -DSIGNALS_DONT_BREAK_READ -DIGNORE_SIGHUP_SIGQUIT  -DDONT_DECLARE_CXA_PURE_VIRTUAL -fno-common -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE  -fno-common  -pipe -fno-common  -Wall -funroll-loops  -c result.c
cc -arch x86_64 -pipe -bundle -undefined dynamic_lookup -o mysql2.bundle client.o mysql2_ext.o result.o -L. -L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib -L. -arch x86_64  -Wl,-rpath,/Applications/XAMPP/xamppfiles/lib    -lruby -L/Applications/XAMPP/xamppfiles/lib -I/Applications/XAMPP/xamppfiles/include -mmacosx-version-min=10.4  -L/Applications/XAMPP/xamppfiles/lib/mysql -lmysqlclient_r -lz -lm  -lpthread -ldl  
ld: -rpath can only be used when targeting Mac OS X 10.5 or later
collect2: ld returned 1 exit status
make: *** [mysql2.bundle] Error 1


Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7 for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql2-0.2.7/ext/mysql2/gem_make.out

ですから、ここでの重要なポイントは次のとおりだと思います。

ld: -rpath can only be used when targeting Mac OS X 10.5 or later

MACOSX_DEPLOYMENT_TARGET=10.6 を設定しようとしましたが、何も変わりません。

ちなみに、私はMac OS X 10.6.6を使用しているので、上記のエラーは意味がありません...

ありがとうございました!

4

1 に答える 1

2

いくつかの可能性を試すことができます。

  1. コマンドに追加--platform=rubyしてみてください。人々がそれが役立つと主張しているのを見てきました。

    コマンドは次のようになります。

    gem install mysql2 --platform=ruby --version 0.2.7 -- --with-mysql-dir=/Applications/XAMPP/xamppfiles/ --with-mysql-lib=/Applications/XAMPP/xamppfiles/lib/mysql/ –with-mysql-include=/Applications/XAMPP/xamppfiles/include/mysql/ --with-mysql-config=/Applications/XAMPP/xamppfiles/bin/mysql_config
    
  2. 正しいアーキテクチャ用に構築していることを確認してください。OSX 10.6.x は、少なくとも私が知る限り、いつ 32 ビットのものを使用し、いつ 64 ビットのものを使用するかについて非常にあいまいです。

    MySQL の 32 ビット バージョンと 64 ビット バージョンの両方に対してビルドを試す必要があります。

    これを行う最も簡単な方法は、http://dev.mysql.com/downloads/mysql/#downloadsから両方をダウンロードし、それぞれに対してビルドを試みることです。

于 2011-12-22T03:42:07.413 に答える