Issues with mysql 2.7 gem

I’ve been trying to get a rails development setup running on my Leopard install. After managing to get the mysql gem installed without errors, I can’t use the gem in any projects.

When I run rake db:migrate, I get the following error:

G5:ag $ rake db:migrate(in /Users/xxx/Projects/ag)
dyld: lazy symbol binding failed: Symbol not found: _mysql_init
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle
Expected in: dynamic lookupdyld: Symbol not found: _mysql_init
Referenced from: /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle
Expected in: dynamic lookup
Trace/BPT trap

If anyone knows what the problem is, and has a solution, please let me know by leaving a comment!

EDIT:Thanks to Chris for doing the hard and blogging about it on this blog post  which appears to solve this problem. I’ll post here again once I have tried this solution.

Rails gem install mysql throws error: *** extconf.rb failed ***

Whilst reading guides on how to setup a rails dev server under OS X (both Tiger and Leopard), I kept running into issues installing the mysql gem. The guides would instruct you to install the mysql client libraries from the mysql website, which is fine. But to get improved performance under rails, you must install the mysql gem, but in doing so, I would constantly run into issues getting the gem to install correctly. The issues normally arises after running the following command:

sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql

And the resulting error is:

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.

Basically, the gem compile fails as a result of not knowing where the correct mysql files are, despite the fact that the command line switch points to the mysql folder.

To fix this problem, use a line like the following:

sudo gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

Note that instead of pointing at the mysql folder, we are pointing at a mysql config which is bundled with the mysql client install files.