
I recently tried to use the image_science gem for Ruby, but it didn’t work after installation because it was looking for FreeImage.h. Thinking it’d be an easy fix, I headed over to http://freeimage.sourceforge.net/ to go grab a copy of a binary file to install, but there wasn’t one.
Undeterred, I went to grab the source and compile it myself. It didn’t work. Eventually I figured there were two key issues:
- FreeImage’s source was prepared for Mac OS X 10.3 (Panther)
- FreeImage was trying to compile for i386 (32-bit) and my Ruby install is x86-64 (64-bit)
First problem is easy to fix, just replace both instances of /Developer/SDKs/MacOSX10.3.9.sdk with /Developer/SDKs/MacOSX10.6.sdk (or, 10.5 for Leopard, or 10.4u for Tiger).
The second part was a bit more fiddly because I wasn’t sure if order was important, so I started by replacing all instances of i386 and I386 with x86_64 and X86_64 respectively. Then, I replaced all instances of ppc and PPC with i386 and I386.
If you don’t want to worry about making all these changes, you can simply download my Makefile.osx here. It’s built for Snow Leopard, but it’s easy to change it for Leopard or Tiger.
thanks very much! this was very helpful indeed :) this way it builds a fat library, that contains both intel archs – i386 and the 64bit _x86_64. i will see, if my 64bit project compiles.
and does this worked at the end?
Pingback: Double Shot #565 « A Fresh Cup
It certainly seems to have worked, yeah. I’ve not done much in the way of image related tasks, but all the warnings I was getting upon booting my Rails app have gone away.
Seems to have worked for me, too. Thanks for posting this!
King among men, thank you.
Is there a better (read: more updated) library to use?
@Joshua: I’m not sure. I’m not very familiar with FreeImage, I just needed to get it working so that a Rails app I was working on could boot properly.