hoodwink.d enhanced
 

juretta.com

Ruby: Installing Ruby MySQL driver on Intel Macs | October 13, 2006-->

October 13, 2006

Installing the native MySQL-Driver for Ruby on my MacBook Pro (Mac OS X 10.4.8) resulted in the following error after running
sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql.

[...]
Building native extensions.  This could take a while...
mysql.c: In function Init_mysql:
mysql.c:2015: error: ulong undeclared (first use in this function)
mysql.c:2015: error: (Each undeclared identifier is reported only once
mysql.c:2015: error: for each function it appears in.)

It seems that ulong hasn't been declared in mysql.c You've got to add #define ulong unsigned long to mysql.c before you can compile the sources on a intel based mac.

I created a small patch file which you can use if you like (i assume that you have MySQL installed in /usr/local/mysql and that your Ruby Gem INSTALLATION DIRECTORY installation is /usr/local/lib/ruby/gems/1.8 - you can check this running gem environment).

# fetch patch file
cd /tmp; 
curl -O http://download.juretta.com/ruby/mac-install/\
intel-mac-mysql-gem.patch

# Assuming that Ruby Gems is located in /usr/local ...
cd /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7

# Makefile
sudo ruby extconf.rb install mysql -- \
--with-mysql-dir=/usr/local/mysql/

# Backup
sudo cp mysql.c mysql.c-orig

# Patch mysql.c
sudo patch mysql.c /tmp/intel-mac-mysql-gem.patch

# Make
sudo make
# Install
sudo make install

For your convenience there is shell script that builds the native mysql gem including the patch.
Just run

macbook:~ stefan$ curl http://download.juretta.com/ruby/mac-install/\
fix-mysql-gem-intel-mac.sh | /bin/bash

You must provide your superuser password. !Please look at http://download.juretta.com/ruby/mac-install/fix-mysql-gem-intel-mac.sh before you run the script! It might do evil... (it won't though)


Diggman

Related Entries


1
Maxime says:
Avatar Wed Oct 25 15:09:27 +0200 2006 | #

Thanks for the detailed help. It solves my problem on my powerpc powerbook.

2
Bill says:
Avatar Fri Dec 01 22:49:10 +0100 2006 | #

You truly saved my sanity. Thanks so, so much. This works like a charm, and I no longer have to look at all the “Lost connection to MySQL” error messages again.

3
Casper Kaandorp says:
Avatar Mon Dec 11 22:11:22 +0100 2006 | #

THANKS A MILLION! I finally can get to work.

4
Mat says:
Avatar Sun Dec 24 17:45:24 +0100 2006 | #

claps Nice work. Now if only we could track down why this patch doesn’t get added to the rubyforge project. I suppose it’s a little more complicated to make it cross platform, but still…
Anyway, thanks a bunch! You’re a life saver!

5
gomez says:
Avatar Thu Apr 05 06:56:46 +0200 2007 | #

thanks a lot from cologne

6
Daryl Wilding-McBride says:
Avatar Sat Apr 21 00:57:47 +0200 2007 | #

Thanks for this script. It solved my problem on my OS X 10.4.9 PowerMac. Really appreciate the contribution.

7
BZ says:
Avatar Fri Jul 13 21:38:03 +0200 2007 | #

I made sure /usr/local/mysql/bin was in my $PATH and then I ran this command and it resolved the same error you were having:
gem install mysql——with-mysql-config=/usr/local/mysql/bin/mysql_config

About

juretta.com is the personal workspace of Stefan Saasen. You can send him an email or read more about this site in the „About“ section.

« Previous entry

Ruby Oneliner
posted about 1 year ago

» Next entry

Install Ruby 1.8.5 on Debian Sarge (3.1)
posted about 1 year ago

Related Entries

Recent comment

On: “Attachr.com: OpenID support added

You need to kill this spam stuff!

posted about 1 year ago by entropie

Look!

Latest links  RSS  

More...