3

I got the same error on Ubuntu Server 11.10 x64 mentioned in some other posts: Post #1 Post #2

The mysql2 gem cannot be compiled due "cannot find -lmysqlclient_r "

I'm using:

  • Ruby v1.8.7
  • MySQL v5.5.25-1
  • Rails 3.2.3
  • Gem 1.8.24

I installed the package libmysqlclient-dev and it still doesn't work.

The files - libmysqlclient_r.a - libmysqlclient_r.so - libmysqlclient_r.so.18 - libmysqlclient_r.so.18.0.0 are located at /usr/lib/x86_64-linux-gnu/

So I created symlinks in /usr/lib/ Ii still doesn't work :(

Any idea??

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

        /usr/bin/ruby1.8 extconf.rb
checking for rb_thread_blocking_region()... no
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. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H    -I/usr/include/mysql -DBIG_JOINS=1  -fno-strict-aliasing  -g -fPIC -fno-strict-aliasing -g -g -O2  -fPIC  -Wall -funroll-loops  -c mysql2_ext.c
./client.h:16:1: warning: ârb_thread_blocking_regionâ defined but not used [-Wunused-function]
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H    -I/usr/include/mysql -DBIG_JOINS=1  -fno-strict-aliasing  -g -fPIC -fno-strict-aliasing -g -g -O2  -fPIC  -Wall -funroll-loops  -c result.c
result.c: In function ârb_mysql_result_fetch_rowâ:
result.c:258:31: warning: variable âtokensâ set but not used [-Wunused-but-set-variable]
result.c:272:58: warning: variable âtokensâ set but not used [-Wunused-but-set-variable]
result.c:315:33: warning: variable âtokensâ set but not used [-Wunused-but-set-variable]
gcc -I. -I. -I/usr/lib/ruby/1.8/x86_64-linux -I. -DHAVE_MYSQL_H -DHAVE_ERRMSG_H -DHAVE_MYSQLD_ERROR_H    -I/usr/include/mysql -DBIG_JOINS=1  -fno-strict-aliasing  -g -fPIC -fno-strict-aliasing -g -g -O2  -fPIC  -Wall -funroll-loops  -c client.c
client.c: In function ârb_mysql_client_infoâ:
client.c:539:3: warning: variable âwrapperâ set but not used [-Wunused-but-set-variable]
gcc -shared -o mysql2.so mysql2_ext.o result.o client.o -L. -L/usr/lib -L. -Wl,-Bsymbolic-functions -rdynamic -Wl,-export-dynamic -Wl,-rpath,/usr/lib/x86_64-linux-gnu    -lruby1.8 -L/usr/lib/x86_64-linux-gnu -lmysqlclient_r -lpthread -lz -lm -lrt -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
Community
  • 1
  • 1
  • 3
    Did you install both libmysqlclient and libmysqlclient-dev. – Indika K Jun 04 '14 at 00:11
  • possible duplicate of [Ruby gem mysql2 install failing](http://stackoverflow.com/questions/4115126/ruby-gem-mysql2-install-failing) – fab May 02 '15 at 20:09

0 Answers0