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

本文是小编为大家收集整理的关于Rails 3.2.3 MySQL 5.5.1 Mysql2 gem安装失败,ld不兼容的处理方法,想解了Rails 3.2.3 MySQL 5.5.1 Mysql2 gem安装失败,ld不兼容的问题怎么解决?Rails 3.2.3 MySQL 5.5.1 Mysql2 gem安装失败,ld不兼容问题的解决办法?那么可以参考本文帮助大家快速定位并解决问题。

问题描述

我有一个干净的构建系统如下

Ubuntu 11.04

Rvm 1.13.5

红宝石 1.9.3p194

Rails 3.2.3

宝石 1.8.24

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

我正在尝试安装 mysql2 gem (0.3.11) 并遇到以下问题:

 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:~$

第一个问题:有人在 Ubuntu 上使用 MySql 5.5.1 运行 Rails mysql2 吗?我让它在另一个 5.1 的系统上运行.受支持的 MySql 版本上的 gem 描述含糊不清.

第二个问题:有人遇到过这个问题吗?在过去一年左右的时间里,我与 mysql2 gem 解决了各种库问题,但这似乎有所不同.

感谢您的帮助.

顺便说一句:恢复到 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
  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...

本文地址:https://www.itbaoku.cn/post/786804.html