ruby - 在 CentOS 64 位上的 Ruby 1.9.2 中安装 ruby​​gem 'mysql2' 时出现编译器错误

标签 ruby rubygems compiler-errors centos5 mysql2

一个 CentOS 64 位 服务器,带有 Ruby 1.8.7 和 1.9.2

{{没有 RVM,需要没有 RVM 的... 目前所有的 Ruby1.9.2 二进制文件都是 ruby​​19 并且同样可以访问, 所以那里没有 gem-path 或任何类似的映射}}

安装 gem '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

最佳答案

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

要停用此“修复”并能够安装 gem,您可以为编译器定义一个标志:

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

关于ruby - 在 CentOS 64 位上的 Ruby 1.9.2 中安装 ruby​​gem 'mysql2' 时出现编译器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6453102/

相关文章:

ruby-on-rails - 是否可以在本地文件夹中运行 Ruby 和 Rails,而无需先在 Mac OS X 上安装它们?

ios - 在构建用于分析的 iOS 应用程序时编译器错误的原因可能是什么?

ruby - 无法通过 ssl 通过 smtp 发送电子邮件

ruby - 如何使用 Rack 图在不同​​端口上运行两个瘦(或其他)服务器?

ruby-on-rails - rails 3 : Autoscaling workers in Heroku

android - Dagger 2 with Java 8错误编译

ios:<错误>:CGAffineTransformInvert:奇异矩阵

ruby - 使 emacs 自动完成 Ruby 方法

ruby-on-rails - 我将如何过滤掉子文档?

java - jar 中的 jRuby gem 生成目录而不是 jar