2011-12-20 18 views
2

我正試圖在Rails應用上的ruby上安裝一個mysql2寶石。目前,我正在運行Ubuntu 11.04,這是我得到的錯誤,當我運行sudo gem install mysql2bundle install試過很多建議,我該如何安裝mysql2 gem?

Building native extensions. This could take a while... 
ERROR: Error installing mysql2: 
ERROR: Failed to build gem native extension. 

/usr/bin/ruby1.8 extconf.rb 
checking for rb_thread_blocking_region()... no 
checking for rb_wait_for_single_fd()... no 
checking for mysql.h... yes 
checking for errmsg.h... yes 
checking for mysqld_error.h... yes 
creating Makefile 

make 
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -g -fPIC -fno-strict-aliasing -g -g -O2 -fPIC -Wall -funroll-loops -c client.c 
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -g -fPIC -fno-strict-aliasing -g -g -O2 -fPIC -Wall -funroll-loops -c mysql2_ext.c 
./client.h:16:1: warning: ‘rb_thread_blocking_region’ defined but not used 
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -g -fPIC -fno-strict-aliasing -g -g -O2 -fPIC -Wall -funroll-loops -c result.c 
gcc -shared -o mysql2.so client.o mysql2_ext.o result.o -L. -L/usr/lib -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic -Wl,-rpath,/usr/lib/x86_64-linux-gnu -lruby1.8 -L/usr/lib/x86_64-linux-gnu -lmysqlclient_r -lpthread -lz -lm -lrt -ldl -lpthread -lrt -ldl -lcrypt -lm -lc 
/usr/bin/ld: cannot find -lmysqlclient_r 
collect2: ld returned 1 exit status 
make: *** [mysql2.so] Error 1 


Gem files will remain installed in /var/lib/gems/1.8/gems/mysql2-0.3.11 for inspection. 
Results logged to /var/lib/gems/1.8/gems/mysql2-0.3.11/ext/mysql2/gem_make.out 

我試着mysql_config安裝,我已經安裝了的libmysqlclient-dev的和的libmysql-Ruby庫,我試過卸載並重新安裝mysql。它沒有任何作用。我能夠成功安裝MySQL的寶石,但不是mysql2。

我正在運行ruby1.8和Rails 2.3.5。誰能幫我嗎?

回答

1

看看這blog和其他人喜歡它。但最終我建議從11.04升級到11.10。在運行11.04時,我經歷了許多奇怪的錯誤,因爲移至11.10時,一切都更加穩定。

+0

謝謝,我會我試試看。 – 2011-12-23 16:49:56

+0

你有機會升級嗎?如果是這樣,那對你有什麼幫助? – 2012-01-03 15:22:45

+0

我不得不在另一個項目上工作,所以我實際上沒有機會去測試這個。當我回到它時,我會告訴你。 – 2012-01-03 20:44:51

4

試試這個:

命令和apt-get安裝的libmysql-紅寶石

命令和apt-get安裝的libmysqlclient-dev的

sudo的創業板安裝mysql2

1

如果你正在運行的CentOS /紅帽,請嘗試安裝以下軟件包(使用yum):

MySQL-devel-5.5.22-1.el6.x86_64 
MySQL-shared-5.5.22-1.el6.x86_64 
MySQL-shared-compat-5.5.22-2.el6.x86_64