# Gem install mysql2 :: Error cannot find -lmysqlclient\_r

**URL:** <https://www.ruby-forum.com/t/gem-install-mysql2-error-cannot-find-lmysqlclient-r/210508>\
**Category:** Rails\
**Created:** [August 9, 2011, 11:36pm UTC](https://www.ruby-forum.com/t/gem-install-mysql2-error-cannot-find-lmysqlclient-r/210508 "2011-08-09T23:36:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [August 9, 2011, 11:36pm UTC](https://www.ruby-forum.com/t/gem-install-mysql2-error-cannot-find-lmysqlclient-r/210508/1 "2011-08-09T23:36:15Z")

</div>

I install rvm in Fedora 15. like listed in the post:  
[https://plus.google.com/106336405206268952858/posts/g1URhoYF3qk](https://plus.google.com/106336405206268952858/posts/g1URhoYF3qk)

Also like to use MySQL, but when I try to install the gem for mysql2:

gem install mysql2

Script started on Mon 08 Aug 2011 12:48:23 PM CDT  
]0;myredhat@myfedora15:~/rails [?1034h[myredhat@myfedora15 rails]$  
su - [2Pll clear df -h clear [K [K [K [K [K 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 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 -g -pipe -m32 -fPIC -g -static-libgcc -fno-omit-frame-  
pointer -fno-strict-aliasing -DMY\_PTHREAD\_FASTMUTEX=1 -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 -g -pipe -m32 -fPIC -g -static-libgcc -fno-omit-frame-  
pointer -fno-strict-aliasing -DMY\_PTHREAD\_FASTMUTEX=1 -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 -g -pipe -m32 -fPIC -g -static-libgcc -fno-omit-frame-  
pointer -fno-strict-aliasing -DMY\_PTHREAD\_FASTMUTEX=1 -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\_row:

result.c:253:31: warning: variable tokens set but not used [-Wunused-  
but-set-variable]

result.c:267:58: warning: variable tokens set but not used [-Wunused-  
but-set-variable]

result.c:310:33: warning: variable tokens set but not used [-Wunused-  
but-set-variable]

result.c: In function rb\_mysql\_result\_fetch\_fields:

result.c:376:35: warning: comparison between signed and unsigned  
integer expressions [-Wsign-compare]

gcc -shared -o mysql2.so mysql2\_ext.o client.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 -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

Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.2-p290/  
gems/mysql2-0.3.6 for inspection.

Results logged to /usr/local/rvm/gems/ruby-1.9.2-p290/gems/  
mysql2-0.3.6/ext/mysql2/gem\_make.out

]0;myredhat@myfedora15:~/rails [myredhat@myfedora15 rails]$ rpm -qa |  
grep MySQL

[01;31m [KMySQL [m [K-server-5.5.15-1.linux2.6.i386

[01;31m [KMySQL [m [K-devel-5.5.15-1.linux2.6.i386

[01;31m [KMySQL [m [K-shared-compat-5.5.15-1.linux2.6.i386

[01;31m [KMySQL [m [K-client-5.5.15-1.linux2.6.i386

]0;myredhat@myfedora15:~/rails [myredhat@myfedora15 rails]$ uname -a

Linux myfedora15 2.6.38.8-32.fc15.i686 #1 SMP Mon Jun 13 20:01:50 UTC  
2011 i686 i686 i386 GNU/Linux

]0;myredhat@myfedora15:~/rails [myredhat@myfedora15 rails]$ exit

exit

Script done on Mon 08 Aug 2011 12:49:05 PM CDT

I try to upgrade but nothing seems to work… I wonder if this is a  
ruby/gem issue or some missing library in the mysql client. !!!.

THX in advance for the heads up.

Edited 1 time(s). Last edit at 08/09/2011 03:31PM by Bernardino Lopez.
