Rails 3.2.3 MySQL 5.5.1 Mysql2 gem安装失败,导致ld不兼容 [英] Rails 3.2.3 MySQL 5.5.1 Mysql2 gem install fails with ld incompatibilities

查看:250
本文介绍了Rails 3.2.3 MySQL 5.5.1 Mysql2 gem安装失败,导致ld不兼容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个干净的构建系统,如下所示:

Ubuntu 11.04



Rvm 1.13.5



Ruby 1.9.3p194

Rails 3.2.3

Gem 1.8.24

MySql 5.5.24-1(安装在/ usr / local)

我是试图安装mysql2 gem(0.3.11)并得到以下问题:

  pal @ smurf01:〜$ sudo gem install mysql2 
[sudo] pal的密码:
构建本机扩展。这可能需要一段时间...
错误:安装mysql2时出错:
错误:无法构建gem本机扩展。

/usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
检查rb_thread_blocking_region()...是
检查rb_wait_for_single_fd()...是
检查mysql.h ...是
检查errmsg.h ...是
检查mysqld_error.h ...是
创建Makefile
$ b $ make
编译client.c
client.c:函数'rb_raise_mysql2_error':
client.c:98:3:warning:ISO C90 forbids混合声明和代码
client.c:在函数'rb_mysql_client_socket'中:
client.c:590:3:warning:ISO C90禁止混合声明和代码
编译mysql2_ext.c
编译result.c
链接共享对象mysql2 / mysql2.so
/ usr / bin / ld:在搜索-lmysqlclient_r $ b时跳过不兼容的/usr/local/mysql/lib/libmysqlclient_r.so $ b / usr / bin / ld:搜索-lmysqlclient_r时,跳过不兼容的/usr/local/mysql/lib/libmysqlclient_r.a
/ usr / bin / ld:无法找到-lmysqlclient_r
collect2:ld返回1退出状态
make:*** [mysql2.so]错误1


Gem文件将会保持安装在/usr/local/rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11进行检查。
结果记录到/usr/local/rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/ext/mysql2/gem_make.out
pal @ smurf01:〜$

第一个问题:有没有人在Ubuntu上使用MySql 5.5.1运行Rails mysql2?我已经在5.1的另一个系统上运行它。第二个问题:有没有人遇到过这个问题?在过去的一年左右,我已经与mysql2 gem发生了各种各样的库问题,但这似乎有所不同。



任何帮助都会感激不尽。



BTW:恢复到MySql 5.1是一个有效的解决方案!



问候

因此,这个问题似乎是一个缺失的库和一些链接。

做到以下几点解决了这个问题。



获取新的并安装由Nathan Rennie Waldock亲切提供的libmysqlclient-dev deb包

  wget http://ppa.launchpad.net/nathan-renniewaldock/ppa/ubuntu/pool/main/m/mysql-5.5/libmysqlclient-dev_5.5.24-1~ ppa1〜natty_amd64.deb ./; l 
dpkg -i libmysqlclient-dev_5.5.24-1〜ppa1〜natty_amd64.deb

然后创建一些mysql2需要的链接,因为它似乎无法遵循mysql路径

  cd / usr / lib / 
ln -s /usr/local/mysql-5.5.24-linux2.6-x86_64/lib/libmysqlclient_r.a。
ln -s /usr/local/mysql-5.5.24-linux2.6-x86_64/lib/libmysqlclient_r.so。
ln -s /usr/local/mysql-5.5.24-linux2.6-x86_64/lib/libmysqlclient_r.so.18。
ln -s /usr/local/mysql-5.5.24-linux2.6-x86_64/lib/libmysqlclient_r.so.18.0.0。

现在快乐地安装mysql2 gem

  sudo gem install mysql2 
获取:mysql2-0.3.11.gem(100%)
构建原生扩展。这可能需要一段时间...
成功安装mysql2-0.3.11
1个安装gem
为mysq2l-0.3.11安装ri文档...
安装RDoc文档mysql2-0.3.11 ...


I have a clean build system as follows

Ubuntu 11.04

Rvm 1.13.5

Ruby 1.9.3p194

Rails 3.2.3

Gem 1.8.24

MySql 5.5.24-1 (installed in /usr/local)

I am trying to install the mysql2 gem (0.3.11) and getting the following problem:

 pal@smurf01:~$ sudo gem install mysql2
   [sudo] password for pal: 
   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.3-p194/bin/ruby extconf.rb
   checking for rb_thread_blocking_region()... yes
   checking for rb_wait_for_single_fd()... yes
   checking for mysql.h... yes
   checking for errmsg.h... yes
   checking for mysqld_error.h... yes
   creating Makefile

   make
   compiling client.c
   client.c: In function 'rb_raise_mysql2_error':
   client.c:98:3: warning: ISO C90 forbids mixed declarations and code
   client.c: In function 'rb_mysql_client_socket':
   client.c:590:3: warning: ISO C90 forbids mixed declarations and code
   compiling mysql2_ext.c
   compiling result.c
   linking shared-object mysql2/mysql2.so
   /usr/bin/ld: skipping incompatible /usr/local/mysql/lib/libmysqlclient_r.so when searching for -lmysqlclient_r
   /usr/bin/ld: skipping incompatible /usr/local/mysql/lib/libmysqlclient_r.a when searching for -lmysqlclient_r
   /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.3-p194/gems/mysql2-0.3.11 for inspection.
   Results logged to /usr/local/rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/ext/mysql2/gem_make.out
 pal@smurf01:~$

First question: Has anyone got Rails mysql2 running with MySql 5.5.1 on Ubuntu? I have it running on another system with 5.1. The gem description is vague on supported MySql versions.

Second question: Has anyone encountered this problem? I± have battled various library issues with the mysql2 gem over the passed year or so but this seems to be different.

Any assistance is gratefully recieved.

BTW: Reverting back to MySql 5.1 is a valid solution!

Regards

Peter

解决方案

So the problem appears to have been a missing library and some links. Doing the following solved the issue.

Get the new and install the libmysqlclient-dev deb package kindly provided by Nathan Rennie Waldock

 wget http://ppa.launchpad.net/nathan-renniewaldock/ppa/ubuntu/pool/main/m/mysql-5.5/libmysqlclient-dev_5.5.24-1~ppa1~natty_amd64.deb./;l
 dpkg -i libmysqlclient-dev_5.5.24-1~ppa1~natty_amd64.deb

Then create some links that mysql2 needs as it can't seem to follow the mysql path

cd /usr/lib/
ln -s /usr/local/mysql-5.5.24-linux2.6-x86_64/lib/libmysqlclient_r.a .
ln -s /usr/local/mysql-5.5.24-linux2.6-x86_64/lib/libmysqlclient_r.so .
ln -s /usr/local/mysql-5.5.24-linux2.6-x86_64/lib/libmysqlclient_r.so.18 .
ln -s /usr/local/mysql-5.5.24-linux2.6-x86_64/lib/libmysqlclient_r.so.18.0.0 .

Now happily install the mysql2 gem

sudo gem install mysql2
  Fetching: mysql2-0.3.11.gem (100%)
  Building native extensions.  This could take a while...
  Successfully installed mysql2-0.3.11
  1 gem installed
  Installing ri documentation for mysq2l-0.3.11...
  Installing RDoc documentation for mysql2-0.3.11...

这篇关于Rails 3.2.3 MySQL 5.5.1 Mysql2 gem安装失败,导致ld不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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