在Debian Squeeze上安装mysql2 gem时出错 [英] Error installing mysql2 gem on Debian Squeeze

查看:178
本文介绍了在Debian Squeeze上安装mysql2 gem时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Debian Squeeze上安装mysql2 gem时,我得到了这个受欢迎的错误:

  gem install mysql2 
Building本地扩展。这可能需要一段时间...
错误:安装mysql2时出错:
错误:无法构建gem本机扩展。

/usr/local/rvm/rubies/ruby-1.9.2-p290/bin/ruby extconf.rb
检查rb_thread_blocking_region()...是
检查rb_wait_for_single_fd()... no
检查mysql.h ...是
检查errmsg.h ...是
检查mysqld_error.h ...是
创建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-brackethes -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-brackethes -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-brackethes -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:有符号和无符号整数表达式之间的比较
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 /本地/ 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:找不到-lmysqlclient_r
collect2:ld返回1退出状态
make:*** [mysql2.so]错误1


宝石文件将保留在/usr/local/rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.11中进行检查。
结果记录到/usr/local/rvm/gems/ruby-1.9.2-p290/gems/mysql2-0.3.11/ext/mysql2/gem_make.out

在堆栈溢出中有很多搜索结果,但没有一个可以解决我的问题。

  libmysqlclient-dev  -  MySQL数据库开发文件
libmysqlclient18 - MySQL数据库客户端库

是通过dot deb repo安装的。



还安装了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


解决方案

看起来本机扩展的问题是缺少头文件(.h)
它们通常位于 -dev 库中

 code> sudo apt-get install libmysqlclient-dev 

gem install mysql2

解决Debian / Ubuntu的问题。


I got this "popular" error while installing mysql2 gem on Debian Squeeze:

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

There are a lot of search results at stack overflow but none of them would fix my Problem.

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

are installed via dot deb repo.

mysql-server is installed, too.

The following files related to libmysqlclient could be found at /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

解决方案

It seems the the problem with the native extensions is the lack of the header files (.h) They are typically found in the -dev libraries

sudo apt-get install libmysqlclient-dev

gem install mysql2

solves the problem for Debian/Ubuntu.

这篇关于在Debian Squeeze上安装mysql2 gem时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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