Compiling RMagick on OS X 10.4.9 Intel

by Jason on Apr 26, 2007


Above: Billy Crystal and Meg Ryan debate pre-built binaries vs. compiling from source in the movie When Harry Met Sally (1989).

Compiling From Source

Have you out-grown Locomotive and decided to compile your rails and RMagick install from the source? Did you have trouble getting RMagick to work on your OS X installation? Do you just enjoy pain? Read on!

This all started for me when using the validates_captcha plugin. I kept getting [BUG] Bus Error in my mongrel logs and the mongrel process would just crash on my local server. The problem turned out to be with RMagick. More specifically, I was able to narrow it down to when it tried to insert text programatically. For those of you having difficulty installing RMagick on your Intel Macs, give these instructions a try, but only if you don't already have a good working install of RMagick. Trust me, don't ruin a good thing.

Prerequisites

I'm going to assume you've already compiled Ruby, Rails, Subversion, Mongrel, and MySQL. The first half of these instructions is reproduced with permission directly from Building RMagick on Mac OS X. A big thanks to Dan Benjamin for that one.

I deviate after that and install GraphicsMagick instead of ImageMagick because I just couldn't get ImageMagick to work without that darn [BUG] Bus Error message. Anyway, this isn't terribly interesting, so I'll just plunge right in. You should probably do all of these things in this order, by the way


FreeType

curl -O http://download.savannah.gnu.org/releases/freetype/freetype-2.1.10.tar.gz
tar xzvf freetype-2.1.10.tar.gz
cd freetype-2.1.10
./configure --prefix=/usr/local
make
sudo make install
cd ..


Lib PNG

curl -O http://superb-west.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.10.tar.bz2
bzip2 -dc libpng-1.2.10.tar.bz2 | tar xv
cd libpng-1.2.10
./configure --prefix=/usr/local
make
sudo make install
cd ..


Lib JPEG

curl -O ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz
tar xzvf jpegsrc.v6b.tar.gz
cd jpeg-6b
ln -s `which glibtool` ./libtool
export MACOSX_DEPLOYMENT_TARGET=10.4
./configure --enable-shared --prefix=/usr/local
make
sudo make install
cd ..


Lib TIFF

curl -O ftp://ftp.remotesensing.org/libtiff/tiff-3.8.2.tar.gz
tar xzvf tiff-3.8.2.tar.gz
cd tiff-3.8.2
./configure --prefix=/usr/local
make
sudo make install
cd ..


Ghostscript Fonts

curl -O http://superb-west.dl.sourceforge.net/sourceforge/gs-fonts/ghostscript-fonts-std-8.11.tar.gz
tar zxvf ghostscript-fonts-std-8.11.tar.gz
cd fonts
sudo mkdir /usr/local/share/ghostscript/fonts
sudo cp * /usr/local/share/ghostscript/fonts
cd ..


Now, GraphicsMagick requires a small patch in order to work right with os x. You can download the patched coders.c here (included below) or modify it yourself with the instructions here.

GraphicsMagick

curl -O http://superb-east.dl.sourceforge.net/sourceforge/graphicsmagick/GraphicsMagick-1.1.7.tar.gz
tar zxvf GraphicsMagick-1.1.7.tar.gz
cd GraphicsMagick-1.1.7
cd coders
curl -O http://www.railsenvy.com/assets/2007/4/5/png.c
cd ..
./configure --with-jbig=no --with-wmf=no --with-dps=no --with-lcms=no --with-x=no --with-perl=no --with-trio=no --with-jp2=no --with-fpx=no --with-png=yes --with-tiff=yes --with-bzlib=yes --with-zlib=yes --with-xml=no --with-ttf=yes --enable-shared=yes --prefix=/usr/local
make
sudo make install


RMagick

curl -O http://rubyforge.org/frs/download.php/19091/RMagick-1.15.5.tar.gz
tar zxvf RMagick-1.15.5.tar.gz
cd cd RMagick-1.15.5
./configure --with-graphics-magick --prefix=/usr/local
make
sudo make install


Hope that helps.

AddThis Social Bookmark Button Tags: osx rmagick  | permalink


Comments

Leave a response

dysingerApril 26, 2007 @ 06:18 PM

I’ve noticed a difference in the rendering on graphicsmagick vs imagemagick that does not favor graphicsmagick. Here’s my script:

curl -O ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.2.16.tar.gz tar xvzf libpng-1.2.16.tar.gz cd libpng-1.2.16 ./configure—prefix=/usr/local make sudo make install cd ..

curl -O ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz tar xvzf jpegsrc.v6b.tar.gz cd jpeg-6b ln -s `which glibtool` ./libtool export MACOSX_DEPLOYMENT_TARGET=10.4 ./configure—enable-shared—prefix=/usr/local make sudo make install cd ..

curl -O ftp://ftp.remotesensing.org/libtiff/tiff-3.8.2.tar.gz tar xvzf tiff-3.8.2.tar.gz cd tiff-3.8.2 ./configure—prefix=/usr/local make sudo make install cd ..

curl -O http://download.savannah.gnu.org/releases/freetype/\ freetype-2.3.2.tar.gz tar xvzf freetype-2.3.2.tar.gz cd freetype-2.3.2 ./configure—prefix=/usr/local make sudo make install cd ..

curl -O ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/AFPL/gs854/\ ghostscript-8.54.tar.gz tar xvzf ghostscript-8.54.tar.gz cd ghostscript-8.54 ./configure—prefix=/usr/local make sudo make install cd ..

curl -O ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/AFPL/gs854/\ ghostscript-fonts-std-8.11.tar.gz tar zxvf ghostscript-fonts-std-8.11.tar.gz sudo chown -R root:wheel fonts sudo rm -rf /usr/local/share/ghostscript/fonts sudo mv fonts /usr/local/share/ghostscript

curl -O ftp://ftp.imagemagick.org/pub/ImageMagick/\ ImageMagick-6.3.3-5.tar.gz tar xvzf ImageMagick-6.3.3-5.tar.gz cd ImageMagick-6.3.3 ./configure—prefix=/usr/local—disable-static—with-modules—without-perl\ —without-magick-plus-plus—with-quantum-depth=8 make sudo make install cd ..

sudo gem install rmagick


Mr FunkApril 26, 2007 @ 08:16 PM

That’s just awful. But I suppose no worse than having to checkout / compile ruby and rails from the terminal. I just couldn’t get comforatble with locomotive. I can’t believe it’s 2007 and even with the goodness that is Ruby we’re still trying to swim with the cinderblock that is ImageMagick tied around our necks like it’s 1999 and we’re rocking PHP3 :(

JRuby could be our saviour :)


CApril 26, 2007 @ 09:55 PM

I’d recommend getting macports and then running:

sudo port install freetype ghostscript rb-rmagick rb-rubygems

That will give you: Ruby 1.8.6 RubyGems 0.9.2 RMagick and Imagemagick configured and working


Jason SeiferApril 26, 2007 @ 10:14 PM

dysinger: Thanks, always good to have options.

C: I tried that originally, and it never worked out for me. That’s why I had to go the route of compiling my own.

Mr Funk: PHP3 4 EVA!! JRuby definitely does look promising.


DylanApril 27, 2007 @ 09:21 AM

I was having trouble getting the rmagick-1.15.5. RMagick has now been updated 1.15.6. Thanks for the help – my failed rmagick + imagemagick installation was causing me grief


DylanApril 27, 2007 @ 10:02 AM

Ah bugger I’m using fleximage plugin, I was receiving “ImageMagick library function failed to return a result.” with image magick. Now it is “GraphicsMagick library function failed to return a result.”


Sorry, comments are closed for this Post, but feel free to email Gregg & Jason with your input. We'd love to hear it.