数据库
首页 > 数据库> > 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

Ruby 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版本上含糊不清.

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

感谢任何帮助.

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

问候

彼得

解决方法:

或者只是apt-get install libmysqlclient-dev然后gem install mysql2

标签:mysql,ruby-on-rails-3,gem,ubuntu-11-04,mysql2
来源: https://codeday.me/bug/20190713/1447208.html