Symbol lookup error in mysql gem

I’ve been having a problem where the rails server (either WEBrick or
Mongrel) hangs and becomes unresponsive overnight. I read some posts
that caused me to think this might be an issue with Ruby’s MySQL
driver, so I thought I would try the mysql gem. I ran:

gem install mysql --include-dependencies – --build-options --with-
mysql-config=/depot/bin/mysql_config

picked “mysql 2.7 (ruby)” (because I’m running on RedHat Linux) and
got a message that the gem had successfully been installed.

However, as soon as my application tries to access the database, I get
the following error (and Mongrel crashes):

ruby: symbol lookup error: /depot/packages/ruby-1.8.5-p2-bin/lib/ruby/
gems/1.8/gems/mysql-2.7/lib/mysql.so: undefined symbol:
_intel_fast_memcpy

Does anyone have any idea what might be the cause? It seems odd that
something would compile successfully, but then crash when running. I
get the same error if I try to access the database from script/
console.

   --Paul

Paul E. G. Lynch wrote:

console.
You have a version of MySQL compiled with the Intel compiler and the
Ruby MySQL library hasn’t been linked against the additional Intel
libraries. Here’s an example of how to fix this in Perl DBD::mysql:

http://coding.derkeiler.com/Archive/Perl/comp.lang.perl.modules/2006-08/msg00224.html

It might give you some ideas on how to fix it with Ruby.


Michael W.

Thanks-- this helped me to get the C-based mysql driver compiled and
working. Also, it appears that the installation of this gem made the
overnight-hang problem go away (though I have only had it running for
about 36 hrs, so it is maybe a little early to be sure). In case
anyone is having the same problem in getting the C-based mysql driver
to work, here are the steps I took:

  1. Install the mysql gem, e.g.:
    gem install mysql --include-dependencies – --build-options --with-
    mysql-config=/depot/bin/mysql_config

  2. Download the Intel CC libraries that were used to compile MySQL
    from:
    http://dev.mysql.com/downloads/os-linux.html
    (There is probably another page to use if you aren’t working on a
    Linux machine). You have to pick the libraries corresponding to your
    machine’s architecture, and also need to pick a version number (for
    which I used the latest and hoped for the best.) I unpacked these
    into:
    /depot/packages/intel-icc9-libs-9.0-i386

  3. Manually edit the mysql gem Makefile. This file is actually
    generated during the installation, so this is not an ideal solution,
    but I couldn’t find a better one. The Makefile is in the top-level
    directory of the installed mysql gem, e.g.:
    /depot/packages/ruby-1.8.5-p2-bin/lib/ruby/gems/1.8/gems/
    mysql-2.7
    The change you need to make is to the LIBS variable in the makefile.
    You have to add a -L option to specify the location of the downloaded
    libraries, and then you need to add a -l option for the “irc”
    library. (I got this from the perl post Michael references;
    otherwise, it would have taken a lot of trial and error.) Here’s what
    my LIBS line looks like:

LIBS = -L/depot/packages/mysql/lib -L/depot/packages/intel-icc9-
libs-9.0-i386 -lmysqlclient -lirc -lz -lcrypt -lnsl -lm -ldl -lcrypt -
lm -lc

  1. Run make and then “make install”.

  2. Restart the web server (e.g. Mongrel).