2

Ruby 1.8.7 & 1.9.2を搭載したCentOS 64 ビットサーバー

{{RVM なし、RVM なしで必要...現在、すべての Ruby1.9.2 バイナリは ruby​​19 であり、同様にアクセス可能であるため、gem-path のマッピングなどは存在しません}}

gem 'mysql2' のインストール中にエラーが発生しています...

すべての依存関係がインストールされており、すべてが64 ビット バージョンです ...

すべてのエラーは {./client.h:13: エラー: typedef 'rb_unblock_function_t' の再定義} の種類です

{#warning ruby​​sig.h is obsolete} がこれの理由でしょうか?

コンソール キャプチャ:

#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
4

3 に答える 3

8

これは、Ruby 1.8で実行するためにgemに導入されたパッチが原因ですが、Ruby1.9では必要ありません。

この「修正」を無効にしてgemをインストールできるようにするには、コンパイラーのフラグを定義できます。

gem install mysql2 -- --with-cflags=\"-DHAVE_RB_THREAD_BLOCKING_REGION\"
于 2013-01-24T16:09:16.907 に答える
1

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

rb_thread_blocking_region()...いいえ

しかし、Ruby 1.9.2はrb_thread_blocking_regionを定義しています(私が知らないifdefと編集のファンキーなセットでRubyを構築した場合を除きます)。

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 "

その後、mysql2gemをビルドすることができました。rvmなどをインストールする必要はありません。

于 2012-06-30T00:34:39.897 に答える
0

それを修正するために私がしたことは、RVM 経由で Ruby を再インストールすることでした。その後、エラーはなくなりました。

または、Ruby 1.8 の rb_thread_blocking_region をエミュレートしようとしている client.h 内のブロックを削除すると、問題なく使用できます。

于 2011-06-26T19:20:26.290 に答える