Topic: MySQL gem ('gem install mysql') fails on Centos 4.4 (and RedHat too).

I'm just posting this work-around, as others may come across the same problem when installing the MySQL gem on to Centos 4.4 (or other distros).

The solution to the problem (below) is simply to make symbolic links to MySQL's lib and include directories.  There is probably a more elegant solution.  Please reply if you know how to change the paths which gem searches, or why MySQL is in the wrong place on RedHat.


root@centos4:~# ln -s /usr/include/mysql /usr/local/include/
root@centos4:~# ln -s /usr/lib/mysql /usr/local/lib/

Problem: (Full text to help those googling this)

root@centos4:~# gem install mysql

Select which gem to install for your platform (i686-linux)
1. mysql 2.7.1 (mswin32)
2. mysql 2.7 (ruby)
3. mysql 2.6 (ruby)
4. mysql 2.5.1 (ruby)
5. Cancel installation
> 2

Building native extensions.  This could take a while...
*** 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.

Provided configuration options:

ERROR:  While executing gem ... (RuntimeError)
    ERROR: Failed to build gem native extension.
Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.

Results logged to /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/gem_make.out