2011-12-12 137 views
7

我,而Debian的挤压安装mysql2宝石得到这个“冷门”的错误:错误安装mysql2宝石挤

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

     /usr/local/rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb 
checking for rb_thread_blocking_region()... yes 
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/usr/local/rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/i686-linux -I/usr/local/rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/usr/local/rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 -I. -DHAVE_RB_THREAD_BLOCKING_REGION -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -D_FILE_OFFSET_BITS=64 -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -g -fPIC -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -fPIC -Wall -funroll-loops -o client.o -c client.c 
gcc -I. -I/usr/local/rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/i686-linux -I/usr/local/rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/usr/local/rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 -I. -DHAVE_RB_THREAD_BLOCKING_REGION -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -D_FILE_OFFSET_BITS=64 -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -g -fPIC -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -fPIC -Wall -funroll-loops -o mysql2_ext.o -c mysql2_ext.c 
gcc -I. -I/usr/local/rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/i686-linux -I/usr/local/rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1/ruby/backward -I/usr/local/rvm/rubies/ruby-1.9.2-p290/include/ruby-1.9.1 -I. -DHAVE_RB_THREAD_BLOCKING_REGION -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H -D_FILE_OFFSET_BITS=64 -I/usr/include/mysql -DBIG_JOINS=1 -fno-strict-aliasing -g -fPIC -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -fPIC -Wall -funroll-loops -o result.o -c result.c 
result.c: In function ‘rb_mysql_result_fetch_fields’: 
result.c:381: warning: comparison between signed and unsigned integer expressions 
gcc -shared -o mysql2.so client.o mysql2_ext.o result.o -L. -L/usr/local/rvm/rubies/ruby-1.9.2-p290/lib -Wl,-R/usr/local/rvm/rubies/ruby-1.9.2-p290/lib -L. -rdynamic -Wl,-export-dynamic -Wl,-rpath,/usr/lib -Wl,-R -Wl,/usr/local/rvm/rubies/ruby-1.9.2-p290/lib -L/usr/local/rvm/rubies/ruby-1.9.2-p290/lib -lruby -L/usr/lib -lmysqlclient_r -lpthread -lz -lm -lrt -lssl -lcrypto -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 /usr/local/rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.11 for inspection. 
Results logged to /usr/local/rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.11/ext/mysql2/gem_make.out 

有在堆栈溢出了大量的搜索结果,但没有人会解决我的问题。

libmysqlclient-dev - MySQL database development files 
libmysqlclient18 - MySQL database client library 

通过点deb回购安装。

也安装了mysql-server。

相关的libmysqlclient以下文件可能被发现在/ usr/lib目录

/usr/lib/libmysqlclient.so.18 
/usr/lib/libmysqlclient_r 
/usr/lib/libmysqlclient.so 
/usr/lib/libmysqlclient.so.16.0.0 
/usr/lib/libmysqlclient.a 
/usr/lib/libmysqlclient_r.so.16 
/usr/lib/libmysqlclient.so.16 
/usr/lib/libmysqlclient.so.18.0.0 
/usr/lib/libmysqlclient_r.so.16.0.0 
+1

大概是在'libmysqlclient'的错误位置查找的。您可以在自定义配置中使用一些地方吗?此外,如果您可以指出从哪里下载源代码,那么这将有所帮助,然后可能会重现该错误。 –

+0

感谢提到'libmysqlclient-dev',那解决了我的问题 –

回答

21

看来与原生扩展的问题是缺少的头文件(.h)中 它们通常被发现在-dev库中

sudo apt-get install libmysqlclient-dev 

gem install mysql2 

解决了Debian/Ubuntu的问题。

+0

+1谢谢!!这对我也适用:) – SubniC