Ruby On Rails native MySQL Bindings Vs. RMagick

January 2, 2007 by Michael

I’m writing this post in english in hope that more people find it useful…

Some times ago i really had bad problems installing the MySQL Gem 2.7 with Ruby 1.8.2 or 1.8.5 in conjunction with Rails 1.1.6 on Mac OS X 10.4

Compilation failed with:

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.)
mysql.c:2015: error: parse error before numeric constant
mysql.c:2018: error: parse error before numeric constant
make: *** [mysql.o] Error 1
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.)
mysql.c:2015: error: parse error before numeric constant
mysql.c:2018: error: parse error before numeric constant
make: *** [mysql.o] Error 1
ruby extconf.rb install mysql — –with-mysql-dir=/usr/local/mysql
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lm… yes
checking for mysql_query() in -lmysqlclient… no
checking for main() in -lz… yes
checking for mysql_query() in -lmysqlclient… yes
checking for mysql_ssl_set()yes
checking for mysql.h… yes
creating Makefile

The gem would then install with Successfully installed mysql-2.7. Creepy!!! But that damn thing just didn’t work.

After quite some googling i found this one:

Running Rails on OS X with MySQL 5.0.24

It’s all about puting a little

#ifndef ulong 
#define ulong unsigned long
#endif

somewhere in “/usr/include/stdlib.h”.

This tipp is still necessary for MySQL 5.0.24+. Thanks again mate!!

But here the trouble starts….

I put the define in a nice little conditional just in case but bah… It would come down to hunt me…

For my project DailyFratze.de i also need RMagick. Again, the gem (1.14.1, 1.14.0 and 1.13) failed to compile but didn’t tell (on runtime it said “require “RMagick” LoadError: No such file to load — RMagick.so” … ) and installation from source did fail as well with:

setup.rb:655:in `command': system("make") failed (RuntimeError)
from setup.rb:664:in `make'
from setup.rb:1258:in `setup_dir_ext'
from setup.rb:1532:in `__send__'
from setup.rb:1532:in `traverse'
from setup.rb:1530:in `dive_into'
from setup.rb:1530:in `traverse'
from setup.rb:1534:in `traverse'
from setup.rb:1533:in `each'
... 8 levels...
from setup.rb:826:in `__send__'
from setup.rb:826:in `invoke'
from setup.rb:772:in `invoke'
from setup.rb:1578
make: *** [all] Error 1

Damn! After banging my head against the walls, reinstalling ImageMagick and all it’s depencies either direct from source, via i-installer and finally as mentioned here i took a break, visited some porn sites and stuff like that and though, hmm… stdlib.h….

I removed the little define and bam! It’s that easy, RMagick compiles just fine…

From the forums i found i guess other people with the same error message may have the same problem as i had…

I really wish installing a ruby on rails environment would be a less pain in the ass…. somewhere near as easy as developing with rails.

2 comments

  1. Peter wrote:

    Hi Michael,

    I’m having the same issue with RMagick in my Mac OS 10.4.8, after following this article:
    http://hivelogic.com/narrative.....agick_os_x

    I’m getting:

    MissingSourceFile in ProfileController#new
    no such file to load — RMagick.so

    Any ideas please.

    Thanks,

    Peter.

    Posted on March 19, 2007 at 8:28 AM | Permalink
  2. Michael wrote:

    First i’d try to uninstall the gem and try installing rmagick from source and see if it really compiles… i made the experience that the gem wouldn’t tell you it’s failure.

    Then use
    require ‘RMagick’
    in your controller. require_gem or the new gem didn’t work for me.

    I made good experience using darwin ports for imagemagick and it’s needed libraries on some newer projects… much less pain in the ass getting things to work.

    Posted on March 19, 2007 at 8:58 AM | Permalink
Post a Comment

Your email is never published nor shared. Required fields are marked *