2011-06-23 16 views
1

ルビー1.8.7 & 1.9.2コンパイラエラーRubyでrubygem 'mysql2' のインストール中に、CentOSの64ビット

{{NO RVMとCentOSの64ビットサーバ上1.9.2

}}ので、その種の宝石パスか何かのマッピングができない 、 現在、すべてのRuby1.9.2バイナリがruby19と同様にアクセス可能です... RVMせずにそれを必要と宝石のインストール中に「エラーを与えていますmysql2 'は...

は、私はすべての 依存関係がをインストールして、すべてが 64ビット版 ...

All error are of kind {./client.h:13: error: redefinition of typedef ‘rb_unblock_function_t’}

Could {#warning rubysig.h is obsolete} be a reason for this?

コンソールのキャプチャです:

#gem19 install mysql2 -v 0.2.7 -- --with-mysql-dir=/usr/bin --with-mysql-config=/usr/bin/mysql_config --with-mysql-include=/usr/include/mysql 

Building native extensions. This could take a while... 
ERROR: Error installing mysql2: 
     ERROR: Failed to build gem native extension. 

/usr/bin/ruby19 extconf.rb --with-mysql-dir=/usr/bin --with-mysql-config=/usr/bin/mysql_config --with-mysql-include=/usr/include/mysql 
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/usr/include/ruby-1.9.1/x86_64-linux -I/usr/include/ruby-1.9.1/ruby/backward -I/usr/include/ruby-1.9.1 -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -I/usr/include/mysql -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -mtune=generic -Wall -fno-strict-aliasing -fPIC -Wall -funroll-loops -o result.o -c result.c 
In file included from ./client.h:11, 
       from ./mysql2_ext.h:39, 
       from result.c:1: 
/usr/include/ruby-1.9.1/ruby/backward/rubysig.h:14:2: warning: #warning rubysig.h is obsolete 
In file included from ./mysql2_ext.h:39, 
       from result.c:1: 
./client.h:13: error: redefinition of typedef ‘rb_unblock_function_t’ 
/usr/include/ruby-1.9.1/ruby/intern.h:754: error: previous declaration of ‘rb_unblock_function_t’ was here 
./client.h:14: error: redefinition of typedef ‘rb_blocking_function_t’ 
/usr/include/ruby-1.9.1/ruby/intern.h:755: error: previous declaration of ‘rb_blocking_function_t’ was here 
./client.h:20: error: static declaration of ‘rb_thread_blocking_region’ follows non-static declaration 
/usr/include/ruby-1.9.1/ruby/intern.h:759: error: previous declaration of ‘rb_thread_blocking_region’ was here 
./client.h: In function ‘rb_thread_blocking_region’: 
./client.h:23: warning: ‘rb_thread_blocking_region_begin’ is deprecated (declared at /usr/include/ruby-1.9.1/ruby/backward/rubysig.h:31) 
./client.h:25: warning: ‘rb_thread_blocking_region_end’ is deprecated (declared at /usr/include/ruby-1.9.1/ruby/backward/rubysig.h:32) 
In file included from ./mysql2_ext.h:39, 
       from result.c:1: 
./client.h:41:7: warning: no newline at end of file 
make: *** [result.o] Error 1 
+0

私は「mysqlの」宝石で「mysql2」宝石を交換し、それがうまく働いている..:

は、「修正」とあなたはコンパイラのフラグを定義することができます宝石をインストールすることができ、これを無効にするにはRails3 Appは現在動作していますが、元の問題は同じままです...そして今、両方の宝石に同じライブラリセットがあります...まだ 'mysql2'宝石ネイティブインストールエラーが発生しましたが 'mysql'は発生しませんでした – AbhishekKr

+0

libmysqlclient-devがインストールされていますか? – Bitterzoet

+0

libmysqlclient-devはDebian/Ubuntuの箱のためのmysql-developmentライブラリです。CentOSの場合、dev-packageはmysql-devel で、x86_64のバージョンがインストールされています... 実際に私は、グループ全体をインストールした後に 'gem install'しようとしました。開発ライブラリのインストールパッケージは、CentOS用のyum経由で利用できます – AbhishekKr

答えて

0

私はそれを修正するためにやりましたRVM経由でRubyを再インストールすることでした。それ以降はそれ以上のエラーはありません。

また、ruby 1.8のrb_thread_blocking_regionをエミュレートしようとしているclient.hのブロックを削除すると、うまくいくでしょう。

1

問題がEXTCONF/mkmfはセクションにあります。

rb_thread_blocking_region()...ない

しかし、あなたはIFDEF年代と編集のいくつかのファンキーなセットでルビー を構築しない限り、Rubyの1.9.2は(rb_thread_blocking_regionを定義します私は気づいていない)。

mkmf.logファイルを確認してください。 Rubyが の rb_thread_blocking_regionをテストするconftest.cファイルをコンパイル/リンクするのに失敗したことを示すはずです。その理由は、libcrypt.a はlibfreebl3に依存していますが、ライブラリはリンク行で を参照していません。

私はそうのような/usr/local/lib/ruby/1.9.1/i686-linux/rbconfig.rb編集することによって、問題を修正:

- CONFIG["LIBS"] = "-lpthread -lrt -ldl -lcrypt -lm " 
+ CONFIG["LIBS"] = "-lpthread -lrt -ldl -lcrypt -lfreebl3 -lm " 

私は後mysql2宝石を構築することができました。 rvmなどをインストールする必要はありません。

7

これは、Ruby 1.8で実行するために宝石に導入したパッチが原因ですが、Ruby 1.9では必要ありません。

gem install mysql2 -- --with-cflags=\"-DHAVE_RB_THREAD_BLOCKING_REGION\" 
関連する問題