Problems installing the memcached gem?


Seeing something like this while compiling libmemcached or trying to install the memcached gem?

checking for style of include used by make... GNU
checking for gcc... gcc
checking for C compiler default output file name...
configure: error: in `/opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/memcached-1.0.2/ext/libmemcached-0.32':
configure: error: C compiler cannot create executables
See `config.log' for more details.
*** 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.

Turns out this error is quite misleading: what I was actually missing was the SASL development headers. This was all easily fixed with:

sudo aptitude install libsasl2-dev
sudo rm -rf /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/memcached-1.0.2/ext/libmemcached-0.32
sudo gem install memcached

(Your path to the gem that failed to install properly could well be different, so double check in your error output from the failed install.)

Compiling FreeImage in 64-bit on Snow Leopard


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:

  1. FreeImage’s source was prepared for Mac OS X 10.3 (Panther)
  2. 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.