Building do_mysql on a 64-bit Mac
Whilst installing merb with edgy I've had run into some trouble building the
do_mysql gem on my Macbook Pro. It's a 64-bit machine, so I installed the 64-bit version of MySQL, and that was my first mistake…
do_mysql gem installed fine. I didn't realise there was a problem until I tried to run some migrations in a blank database:
$ merb -i ~ Loaded DEVELOPMENT Environment... ~ loading gem 'dm-validations' ... ~ loading gem 'merb_datamapper' ... ~ loading gem 'merb-haml' ... ~ loading gem 'dm-core' ... ~ Merb::Orms::DataMapper::Connect block. ~ Connecting to database... ~ Checking if we need to use DataMapper sessions ~ Merb::Orms::DataMapper::Connect complete ~ Parent pid: 9932 ~ Compiling routes... >> Post.auto_migrate! dyld: lazy symbol binding failed: Symbol not found: _mysql_init Referenced from: /Library/Ruby/Gems/1.8/gems/do_mysql-0.9.6/lib/do_mysql_ext.bundle Expected in: dynamic lookup dyld: Symbol not found: _mysql_init Referenced from: /Library/Ruby/Gems/1.8/gems/do_mysql-0.9.6/lib/do_mysql_ext.bundle Expected in: dynamic lookup
Oh dear. I did some Googling, and found a few articles from people having similar problems (e.g. Ben Novakovic, who had problems with the mysql gem).
It turns out that the gems cannot be compiled properly against a 64-bit version of MySQL, as they don't take proper notice of the output of
mysql_config. Chris Cruft investigated the problem and ended up working around it by using the 32-bit version.
ARCHFLAGS environment variable (as suggested in Chris's article) to the output of
mysql_config --cflags didn't work for me either, so I've gone for the same solution as Chris and installed the i386 build of MySQL. The
do_mysql gem now works fine.
If you check the comments on Chris's post you'll see that some people have managed to get the
mysql gem to build properly against 64-bit MySQL. I've opted not to bother trying to shovel lots of command line switches at the problem because I'm installing merb with edgy, and am getting by fine with the 32-bit version for now…
I love feedback and questions — please feel free to get in touch on Mastodon or Twitter, or leave a comment.