Part of what I’m doing is actually learning Rails more than I knew it before. I’ve been working on random test apps, but now I’m trying to build something for real and I decided to start from scratch. Blew everything away, happily compiling/installing on my Mac and then I run into issues.
Basically, I got this error (I was trying to run rake db:migrate) on OS X:
dyld: NSLinkModule() error
dyld: Library not loaded: /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib
Referenced from: /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.bundle
Reason: image not found
Trace/BPT trap
The issue is that in the most recent builds of MySQL from mysql.com (I was using 5.0.41), the libraries are no longer in lib/mysql/ but just in lib. I couldn’t remember how to modify linkage in a compiled bundle, but after a bit of googling, I found a post detailing the answer. Just run:
sudo install_name_tool -change /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib /usr/local/mysql/lib/libmysqlclient.15.dylib
/usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.bundle
That will take care of the issue. You can use the same tool for any library that’s pointing to the wrong place for a link. Not sure why or how this happened, but at some point I’ll probably look into it and submit a patch.






June 6th, 2007 at 1:08 pm
[...] found helpful info here and [...]
June 8th, 2007 at 12:34 am
?
June 16th, 2007 at 1:02 pm
Thanks, this fixed everything.
-s
June 18th, 2007 at 11:09 am
Fantastic, thank you. Fixed things right up.
June 21st, 2007 at 1:32 pm
you’re a life-saver, been looking for a fix for this for soooooo long, thanks a lot
June 23rd, 2007 at 12:10 pm
Thanks, worked perfectly.
June 29th, 2007 at 2:12 am
Fixed it, thanks.
August 10th, 2007 at 7:19 pm
Much appreciated. I’m sure this would have cost me a lot of time had I not found your post.
August 31st, 2007 at 9:54 am
Fixed worked. Thanks a lot, saved alot of time.
September 25th, 2007 at 4:13 pm
Thanks for posting that Google fodder.
October 11th, 2007 at 1:27 pm
Killer. Worked like a charm. You saved me loads of searching.
October 24th, 2007 at 7:08 pm
I really need your help right now… I’m trying to install Radiant CMS which was built with Rails and when I launch the server I get a similar error:
dyld: NSLinkModule() error
dyld: Library not loaded: /usr/local/mysql/lib/libmysqlclient.15.dylib
Referenced from: /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/lib/mysql.bundle
Reason: no suitable image found. Did find:
/usr/local/mysql/lib/libmysqlclient.15.dylib: mach-o, but wrong architecture
Trace/BPT trap
I tried copy and pasting the solution you provided above with no luck. What is going on? I tried starting a new Rails app (not RadiantCMS) and Mongrel launched just fine, it’s only when I try launching Radiant does it give me this error.
October 24th, 2007 at 7:30 pm
Jacob, that error looks like you built the mysql library on the wrong platform… was it built on an Intel Mac and you’re running on a G4 (or vice versa?).
The mysql gem needs to be rebuilt on whatever box you’re on just to make sure…
October 25th, 2007 at 11:43 am
Oh sweet, thanks for answering my cry… I’m running on a G5. Should I uninstall mysql and reinstall it? Did I pick the wrong package on mysql.com? What do you mean ‘built’ and ‘rebuilt’?
October 25th, 2007 at 11:58 am
I downloaded the 32-bit over the 64-bit and the error is gone! woohoo!
October 25th, 2007 at 12:58 pm
Glad you figured it out. Built/Rebuilt just means this: The mysql gem, unlike many, includes a bit of code that needs to be compiled on your local system. Not sure your level of expertise, so bear with me if I’m telling you things you know.
Roughly speaking, the settings when you compile that bit of source code need to match the settings of MySQL when it was compiled by the folks at MySQL.
It looks like they didn’t line up in your case (64/32 would be one of those settings)
December 19th, 2007 at 7:51 am
BIG THANKS! Saves us alot of headache!!!
LOVE from Sweden!
December 25th, 2007 at 8:02 pm
Thanks for this fix, been banging my head for a few hours!
October 1st, 2008 at 3:35 am
I just made a soft link (ln -s . mysql) in the lib dir of de mysql-installation and it works!
Looks pragmatic to me.