The mysql gem and Intel macs

I tried getting rails up and running on my (fairly) new iMac a few days back, and although I installed mysql gem currectly, the code was unable to connect to the mysql server. In fact, it threw an error –

mysql.c:2015: error: ulong undeclared

It befuddled me for a bit, because when the mysql gem is installed (gem list shows it), it compiles the native extensions – and that had succeeded. Or so I thought. Long story short – there appears to be a problem when trying to compile this gem on Intel Macs – and here’s the fix.

1. Go to gems directory – it will be somewhere under your ruby directory. Edit mysql.c, and add “#define ulong unsigned long” to it.
2. Then do ruby extconf.rb install mysql — –with-mysql-dir=yourmysqldirectory/
3. make
4. make install

This fixed things, and now, mysql can be used satisfactorily.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s