Tuesday, June 10, 2008

gem install mysql

Let's pretend you have installed mysql with yum on your fedora box, and you want to install the mysql gem so you can take advantage of it's c binding goodness.

With giddy excitement you bash away at the keyboard and run the following command:

gem install mysql

But wait, what's this? An error the likes of which would consume small children given the chance:

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.

Fear not! For it probably doesn't know how to find you mysql_config file. Try something along the following lines:

sudo gem install mysql -- --with-mysql-config=/usr/lib/mysql/mysql_config

The location of mysql_config may vary depending on your system installation.

No comments: