簡體   English   中英

通過CentOS 64位在Ruby 1.9.2中安裝rubygem'mysql2'時出現編譯器錯誤

[英]compiler error while installing rubygem 'mysql2' in Ruby 1.9.2 over CentOS 64-bit

帶有Ruby 1.8.7和1.9.2CentOS 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中不需要它。

要停用此“修復”並能夠安裝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(除非你用一些我不知道的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 "

我之后能夠構建mysql2 gem。 無需安裝rvm等

我做的是修復它是通過RVM重新安裝Ruby。 之后沒有更多的錯誤。

或者,刪除client.h中試圖為Ruby 1.8模擬rb_thread_blocking_region的塊,你就可以了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM