Installing MySQL Ruby Gem on Mac OS X 10.4

Posted by Max Dunn Wed, 13 Dec 2006 07:14:00 GMT

There are some problems installing the Ruby Gem MySQL on the Mac 10.4. When you do a:

sudo gem install mysql

you will likely get an error like:

*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

To fix this problem, run this:

sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql

(Solution From How to Install on OSX)

Next, you will probably see this error:

mysql.c: In function 'Init_mysql':
mysql.c:2015: error: 'ulong' undeclared (first use in this function)
...

To fix this, change to /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7 and edit “mysql.c” to add this to the top:

#define ulong unsigned long

(Solution from: I.NFECTIO.US)

Now recompile with:

sudo make
sudo make install
sudo make clean

That should do it!

Posted in ,  | 7 comments

Comments

  1. Lorin Rivers said 37 days later:

    Thanks!

    I wish the gem method worked, but hey…

  2. Denny said 84 days later:

    #define ulong unsigned long

    Thank you thank you thank you :)

  3. jsf said 303 days later:

    where should I be when typing the ‘sudo make’, ‘sudo make install’ and the ‘sudo make clean’ above?

    Also, i had to look in this dir:

    /opt/local/lib/ruby/gems/1.8/gems/mysql-2.7

    to try your solution.

    There was no mysql.c but there was a mysql.c.in file…

    Am I hopelessly lost or what?

  4. Max Dunn said 303 days later:

    You should be in the same directory as the mysql.c file. It sounds like your installation wasn’t complete since it was missing this file. You could try searching for it using “locate mysql.c” and if not found, then reinstall the mysql gem.

  5. papyromancer said 339 days later:

    I finally got this working with some help from your blog, and over this way—> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/249986

  6. Roger Pack said 456 days later:

    Thank you much! Worked, but since I had installed mysql via MacPorts, the gem command was ruby extconf.rb—with-mysql-config=/opt/local/bin/mysql_config5

    Thanks.

  7. smo said 536 days later:

    Thanks a bunch, mate!

(leave url/email »)

   Comment Markup Help Preview comment