Camellia and Ruby on Mac OS X
Camellia is ‘an open source Image Processing & Computer Vision library’ that can do some interesting stuff directly from Ruby.
Unfortunately, the Ruby library for Camellia is only available as a RubyGem in two flavours, i386-mswin32 and i486-linux, neither of which is much use if you’re on Mac OS X.
Fortunately, with a bit of work, you can get it to compile. I’ll assume in these instructions that you’re using Ruby from MacPorts. I also can’t guarantee that this works on PowerPC Macs: I’ve only tried it on Intel.
The first prerequisite is the Camellia library itself; that’s a straightforward case of downloading the source (use the ‘Unix/Linux’ distribution), expanding the archive and doing the usual incantation:
./configure && make && sudo make install
For the gem itself, it’s a bit more complicated. There’s no source distribution as such, but it’s easy enough to pick apart the file once you’ve downloaded it (go for the i486-linux gem).
mkdir camellia-gem cd camellia-gem tar xvf ../camellia-2.5.10-i486-linux.gem tar zxvf data.tar.gz cd ext
The only thing that stops the gem compiling out of the box is a couple of linker settings; change the line in extconf.rb that reads
CONFIG['LDSHARED'] = "g++ -shared -lCamellia"
to
CONFIG['LDSHARED'] = "g++ -lCamellia -bundle -flat_namespace -undefined suppress"
You can now build the extension:
ruby extconf.rb && make
You should now have a camellia.bundle file; check whether it has built correctly:
ruby -d -w -e 'require "camellia"'
If you get no errors, everything worked. You can copy camellia.bundle into your site_ruby directory so that it’s available to all programs:
sudo cp camellia.bundle /opt/local/lib/ruby/site_ruby/1.8/
That’s it! Now try some of the demo code ....
2007-05-16 15:42 UTC. Comments: 3.
Tieg
Wrote at 2007-05-16 16:55 UTC using Firefox 2.0.0.3 on Mac OS X:
Nice! Thanks for the pointer; I’ll try this later with /usr/local/lib ruby. Anything that has “camellia” in its name has to be good.Peter Cooper
Wrote at 2007-05-17 16:44 UTC using Firefox 2.0.0.3 on Mac OS X:
I’ve updated the Ruby Inside post with a link to this. Nice detective work :)Marc
Wrote at 2008-06-09 07:48 UTC using Firefox 2.0.0.14) on Mac OS X:
$ makemake: *** No rule to make target `ruby.h’, needed by `camellia_ruby_wrap.o’. Stop.
any idea?
$ ruby -rrbconfig -e ‘puts ::Config::CONFIG[“includedir”]’
/usr/local/include
A ruby.h does exist in /usr/local/include