编译器错误,而安装rubygem'mysql2'在Ruby 1.9.2在CentOS 64位 [英] compiler error while installing rubygem 'mysql2' in Ruby 1.9.2 over CentOS 64-bit

查看:405
本文介绍了编译器错误,而安装rubygem'mysql2'在Ruby 1.9.2在CentOS 64位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CentOS 64位服务器, Ruby 1.8.7& 1.9.2

{{没有RVM,无需RVM ...
目前所有Ruby1.9.2二进制文件都是ruby19和类似地访问,
,所以没有映射宝石路径或任何类别是}}

gem'mysql2' ...

is giving error while installing gem 'mysql2' ...

我已安装所有依赖项,并且都是 64位版本 ...

I have all dependencies installed and all are 64-bit versions ...


所有错误都是{./client.h:13:
错误:redefinition of typedef
'rb_unblock_function_t'}

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

可能{#warning ruby​​sig.h已过时}
是原因吗?

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


推荐答案

通过他们在gem上引入的补丁,以便它在Ruby 1.8中运行,但是在Ruby 1.9上不需要。

This is caused by a patch they introduced on the gem in order for it to run in Ruby 1.8 but it is not needed on Ruby 1.9.

要停用这个修复安装gem可以为编译器定义一个标志:

To deactivated this "fix" and be able to install the gem you can define a flag for the compiler:

gem install mysql2 -- --with-cflags=\"-DHAVE_RB_THREAD_BLOCKING_REGION\"

这篇关于编译器错误,而安装rubygem'mysql2'在Ruby 1.9.2在CentOS 64位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆