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.
by James
04 Mar 2008 at 15:55
Well, I am having the same problem.
Stock 10.5, + mysql package (x86_64 arch) downloaded from mysql.com ; then I got the gem to install using the –with-mysql-config option.
Now having same problem as you.
I investigated mysql.bundle with the nm(1) tool, and it shows a LOT of symbols, including _mysql_init as undefined. I do not know why this is. Should we have installed some development libraries before installing the gem ( =compiling the bindings) ?
Not many other people are reporting this problem, but I assumed the majority of people downloaded the mysql package rather than downloading and building from source, so I don’t know why more people with 10.5 aren’t having this problem.
Have you had any luck?
by Ben Novakovic
04 Mar 2008 at 16:06
@James
No such luck yet. I actually downloaded the mysql (10.4) binary download for PPC and had this problem. I tried downloading the source, and compiling, but it informed me that the binary was already configured and ready to go.
I hope someone can shed some light on this problem.
by RyanR>
06 Mar 2008 at 11:14
I also used the x86_64 mysql package for Leopard today, installed the mysql gem using the –with-mysql-config option, and am getting the same error. Sorry, no light to shed.
by martin
07 Mar 2008 at 10:27
same problem here. my rails app first worked with getting temporarly “mysql lost connection” messages. now the same :
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 lookup
what the f++k.
by Dan
12 Mar 2008 at 11:53
I think the problem is the arch flags on the mysql gem. I originally used:
sudo env ARCHFLAGS=”-arch i386″ gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
To install the gem, and was receiving the same errors as you guys have mentioned. As I’d installed the x86_64 mysql binary, I thought that maybe this might be the problem. So I reinstalled the gem with:
sudo env ARCHFLAGS=”-arch x86_64″ gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config
And now it seems to work, so far.
by Troy
13 Mar 2008 at 09:13
For me, and for whatever damn reason unknown to me, I had the mysql gem in /Library/Ruby/Site/1.8/universal-darwin9.0/mysql.bundle
and also in
/Library/Ruby/Gems/1.8/gems/mysql-2.7/
Deleting /Library/Ruby/Site/1.8/universal-darwin9.0/mysql.bundle fixed my Symbol not found problems
by Ben Novakovic
17 Mar 2008 at 09:45
@Dan & @Troy
Great, thanks for the feedback. I will give this a go tonight!
by Chris
19 Mar 2008 at 22:44
Same problem. Brand new MBP (10.5.2) with XCode 3.0 and dmg installation of MySQL (64-bit). Dan’s solution resolved the problem. I guess the gem builder is not smart enough to pick up the mysql platform -even though mysql_config points it out very nicely:
/usr/local/mysql/bin/mysql_config –cflags
=> -I/usr/local/mysql/include -Os -arch x86_64 -fno-common
by Chris
20 Mar 2008 at 03:35
I spoke too soon and Dan probably did as well.
While forcing the architecture with Dan’s syntax solves the “Symbol not found” errors, I’ve only graduated to a different error: Rails can’t load the gem and whines about having to use the built-in ruby-based mysql driver.
You can see the error more clearly by running the following in the Rail’s console:
require_library_or_gem ‘mysql’
Note the nasty errors!
To be continued…
by Chris
20 Mar 2008 at 22:07
I did a lot more research on this problem with mysql bindings for Ruby. In a nutshell, I eventually bailed out and installed the 32-bit version. Details here:
http://cho.hapgoods.com/wordpress/?p=158
by Zack Green
12 Jun 2008 at 11:02
Chris’ post didn’t work for me because it couldn’t find the x86_64. What did work was
sudo env ARCHFLAGS=”-arch ppc64″ gem install -V mysql — –with-mysql-include=/usr/local/mysql/include/ –with-mysql-lib=/usr/local/mysql/lib –with-mysql-config=/usr/local/mysql/bin/mysql_config –with-mysql-dir=/usr/local/mysql
Source: http://involution.com/category/ruby-on-rails/
by Zack Green
12 Jun 2008 at 11:03
Sorry, that’s “-arch x86_64″. I copy and pasted directly, not my modification.
by Josh Goebel
21 Oct 2008 at 19:02
OK, seriously. I have a REAL solution that actually works though it’s a pain in the ass. You install MySQL 32-bit and then build and link the gem against that and then binary hack the resulting mysql.bundle to use the correct location for the 32-bit libs.
http://blog.pastie.org/2008/10/mysql-64-bit-ruby-32-bit-friends-again.html
by coco
15 Nov 2008 at 18:30
Thanks a lot Dan !!!! It worked !
by kristoph
25 Nov 2008 at 12:23
If you are using a 32-bit version of Ruby, you won’t be able to use the mysql gem with the 64-bit version or mysql (irrespective of the arch directive).
Instead, you can install the pure Ruby MySQL interface from here:
http://www.tmtm.org/en/ruby/mysql/
by Antoine
20 Jan 2009 at 06:29
This article goes into more detail on the problem involving x86 versions of mysql http://craiccomputing.blogspot.com/2008/11/installing-rails-22-on-mac-os-x-mysql.html
by Wayne E. Seguin
28 Jan 2009 at 15:08
I also just ran into this exact issue with DataMapper’s do_mysql gem. After pulling out my hair for a while I compiled mysql by hand and re installed the gems and everything worked perfectly after that. Hope this helps *someone*.
by eluzix
30 Apr 2009 at 22:31
If it’s not a production server i suggest just install MySQL x86 version and reinstall the gem.