Sunday, March 21, 2010

Mac OS X Leopard installing the ruby gem eventmachine

I was having some trouble installing eventmachine (a ruby gem that needs an extension library written in C++) recently in Mac OS X Leopard. I am currently running ruby 1.8.8dev. I think, perhaps, when I compiled ruby from source, the config left out the CXX flags setting. This makes mkmf not know what C++ compiler it needs to set in the Makefiles it creates. Since there are not too many gems that have extensions written in C++ (that I know of), I never really ran into this issue. Here is how to fix this.

Edit this file inside the directory of the gem, in my case;

$ vim /usr/local/lib/ruby/gem/1.8/gem/eventmachine-0.12.11/ext/extconf.rb

Right above the last line (the last line being a call to create_makefile), insert this line:

CONFIG['CXX'] = g++

then do the same thing for this extconf.rb in the fastfilereader dir (or anywhere else in the ext dir where there might be more nested extconf.rb files.

then run this:

cd /usr/local/lib/ruby/gem/1.8/gem/eventmachine-0.12.11; rake gem:install

this should solve the issue of getting errors like this:

make: I.: Command not found
make: dynamic: Command not found