Ruby Gem Mysql on Suse 10

comment 1
computing / internet / programming

If you get the error below while trying to install the ruby mysql gem on Suse 10 then follow the instuctions below to get it going:

incei273:~ # gem install mysql
Building native extensions. This could take a while…
ERROR: While executing gem…
(Gem::Installer::ExtensionBuildError)
ERROR: Failed to build gem native extension.

ruby extconf.rb install mysql
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lm… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lz… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lsocket… no
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lnsl… yes
checking for mysql_query() in -lmysqlclient… no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.

Checking the mkmf.log in:

{ruby-dir}/gems/1.8/gems/mysql-2.7/mkmf.log

… shows libmysql is missing. But looking in /usr/lib/mysql shows some libmysqlclient*.so files but GCC actually needs the .a files.

So fire up yast and install the mysql-devel package.

Then install the Ruby Mysql Gem using:

gem install mysql — –with-mysql-lib=/usr/lib/mysql/

1 Comment

  1. Thanks for the tip — I’d just installed the gem on OS X (Leopard), which had it’s own set of problems, and I would have been barking up the wrong tree entirely if I hadn’t come across your post. :)

Leave a Reply

Your email address will not be published.