通过CentOS 64位在Ruby 1.9.2中安装rubygem\'mysql2\'时发生编译器错误

| 一台具有Ruby 1.8.7和1.9.2的CentOS 64位服务器 {{没有RVM,没有RVM就需要它... 当前,所有Ruby1.9.2二进制文件都是ruby19,并且可以通过类似方式访问, 因此没有gem-path映射或任何类似的内容}} 安装gem \'mysql2 \'时出现错误... 我已经安装了所有依赖项,并且都是64位版本...   所有错误均为{./client.h:13:   错误:重新定义了typedef   ‘rb_unblock_function_t’}      {#warning ruby​​sig.h已过时}   是这个原因吗? 控制台捕获:
#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
    
已邀请:
        这是由他们在gem上引入的补丁引起的,以便使其在Ruby 1.8中运行,但在Ruby 1.9上则不需要。 要停用此\“ fix \”并能够安装gem,可以为编译器定义一个标志:
gem install mysql2 -- --with-cflags=\\\"-DHAVE_RB_THREAD_BLOCKING_REGION\\\"
    
        问题在extconf / mkmf部分中: rb_thread_blocking_region()...否 但是Ruby 1.9.2定义了rb_thread_blocking_region(除非您构建了Ruby 加上一些我不知道的时髦的ifdef和修改)。 检查您的mkmf.log文件。它应该告诉你Ruby失败了 编译/链接测试的conftest.c文件 rb_thread_blocking_region。原因是那个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 gem。无需安装rvm等     
        我要解决的问题是通过RVM重新安装Ruby。此后没有更多错误。 或者,删除client.h中试图模拟Ruby 1.8的rb_thread_blocking_region的块,您会很方便。     

要回复问题请先登录注册