Installing RMagick on Leopard (without MacPorts or Fink)

I’ve recently upgraded to OS X 10.5 (Leopard), and all-in-all, I’m pleased with the experience. My biggest issue has been the default stacks behavior—the icon changes to the last thing added to the stack, making visual identification unnecessarily cumbersome. I worked around this annoyance (as outlined here) by changing the sort to name rather than date added, and adding a dummy folder named “_1” that will sort to the top. For extra bonus points, I customized the icon of the dummy folder. For some yet unknown reason, the most recently downloaded item still peeks through from time to time, but it’s much better than before.

Maybe it’s my Windows history showing through, but I went with the “clean-sweep” erase and install method. For a non-developer, I’d probably recommend the upgrade (and in fact I used that method for my Father-in-law’s MacBook), but I had lots of custom bits scattered about my machine, and didn’t want to be chasing any incompatibility gremlins.

So now, to get my development environment set up on the new machine… Leopard includes a fairly complete Rails stack out of the box, with a non-broken Ruby, readline support, and most of the commonly used gems. Read more here
.

MySQL was not included, but the latest installer (mysql-5.0.45-osx10.4-i686.dmg) for 10.4 from dev.mysql.com downloads worked (mostly) fine. The Server and the StartupItem install and operate correctly. The PrefPane installs, but does not appear to actually do … anything. I’ll have to work on that, but I can live without it for now. After a bit of manual hacking on my database dump file from Tiger (where I was running a 5.1.x beta of MySQL), all my databases are back in place.

One last piece that I needed for my Rails apps—RMagick. I know it’s possible to install RMagick and its dependencies, um, “autoRMagickally” via a package management system like MacPorts or Fink, but I prefer not to. For some background on why not, you can read this article at hivelogic. The last time I was rebuilding my laptop and desktop near the same time, I put together a shell script to automate the process of installing RMagick. I got it back out and dusted off the cobwebs, and voila! RMagick on Leopard. (note: replace wget with “curl -O”, if you don’t have wget installed on your machine) Here’s the code:

install_rmagick.sh

#!/bin/sh
wget http://download.savannah.gnu.org/releases/freetype/freetype-2.3.5.tar.gz
tar xzvf freetype-2.3.5.tar.gz
cd freetype-2.3.5
./configure —prefix=/usr/local
make
sudo make install
cd ..

wget http://superb-west.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.22.tar.bz2
tar jxvf libpng-1.2.22.tar.bz2
cd libpng-1.2.22
./configure —prefix=/usr/local
make
sudo make install
cd ..

wget 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.5
./configure —enable-shared —prefix=/usr/local
make
sudo make install
cd ..

wget 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 ..

wget http://jaist.dl.sourceforge.net/sourceforge/wvware/libwmf-0.2.8.4.tar.gz
tar xzvf libwmf-0.2.8.4.tar.gz
cd libwmf-0.2.8.4
make clean
./configure
make
sudo make install
cd ..

wget http://www.littlecms.com/lcms-1.17.tar.gz
tar xzvf lcms-1.17.tar.gz
cd lcms-1.17
make clean
./configure
make
sudo make install
cd ..

wget ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/GPL/gs860/ghostscript-8.60.tar.gz
tar zxvf ghostscript-8.60.tar.gz
cd ghostscript-8.60/
./configure —prefix=/usr/local
make
sudo make install
cd ..

wget ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/GPL/current/ghostscript-fonts-std-8.11.tar.gz
tar zxvf ghostscript-fonts-std-8.11.tar.gz
sudo mv fonts /usr/local/share/ghostscript

wget http://imagemagick.site2nd.org/imagemagick/ImageMagick-6.3.5-9.tar.gz
tar xzvf ImageMagick-6.3.5-9.tar.gz
cd ImageMagick-6.3.5
export CPPFLAGS=-I/usr/local/include
export LDFLAGS=-L/usr/local/lib
./configure —prefix=/usr/local —disable-static —with-modules —without-perl —without-magick-plus-plus —with-quantum-depth=8 —with-gs-font-dir=/usr/local/share/ghostscript/fonts
make
sudo make install
cd ..

sudo gem install RMagick

Posted by Solomon White Sat, 03 Nov 2007 00:07:00 GMT


Comments

  1. jim about 12 hours later:

    you can replace wget with “curl -O” since wget ins’t installed by default on Leopard.

  2. gissmoh about 13 hours later:

    there’s a problem with the hostname:

    -13:34:46- http://imagemagick.site2nd.org/imagemagick/ImageMagick-6.3.5-9.tar.gz
    => `ImageMagick-6.3.5-9.tar.gz’
    Auflösen des Hostnamen »imagemagick.site2nd.org«…. 208.101.21.223
    Verbindungsaufbau zu imagemagick.site2nd.org|208.101.21.223|:80…
    fehlgeschlagen: Operation timed out.
    Erneuter Versuch.

    -13:36:02- http://imagemagick.site2nd.org/imagemagick/ImageMagick-6.3.5-9.tar.gz
    (Versuch: 2) => `ImageMagick-6.3.5-9.tar.gz’
    Verbindungsaufbau zu imagemagick.site2nd.org|208.101.21.223|:80… fehlgeschlagen: Operation timed out.
    Erneuter Versuch.

  3. gissmoh about 13 hours later:

    wget http://imagemagick.site2nd.org/imagemagick/ImageMagick-6.3.5-9.tar.gz
    tar xzvf ImageMagick-6.3.5-9.tar.gz

    does not work … unknown host!!

    I replaced it with:

    wget ftp://ftp.fu-berlin.de/unix/X11/graphics/ImageMagick/ImageMagick-6.3.6-4.tar.gz
    tar xzvf ImageMagick-6.3.6-4.tar.gz
    cd ImageMagick-6.3.6
    export CPPFLAGS=-I/usr/local/include
    export LDFLAGS=-L/usr/local/lib
    ./configure —prefix=/usr/local —disable-static —with-modules —without-perl —without-magick-plus-plus —with-quantum-depth=8 —with-gs-font-dir=/usr/local/share/ghostscript/fonts
    make

    …and everything works fine….

  4. Solomon about 15 hours later:

    @jim: yes, I installed wget before setting up RMagick, but “curl -O” works for a stock installation.

    @gissmoh : yes, this script uses mirrors that are close to me. YMMV depending on prevailing network conditions.

    Thanks for the updates!

  5. Ryan Stout 6 days later:

    I just wanted to say thanks, this script saved me a lot of thinking. I can’t believe the whole script worked fine. Having been on linux for so long, I just expected something to go wrong. I guess that’s the benefit of not having a bunch of different distros.

  6. John Smith 7 days later:

    Many thanks for compiling all the necessary dependencies in one place. It was a nightmare trying get rmagik to work when I got my laptop last December.

  7. Chris Griffin 8 days later:

    The original ftp url for the jpeg lib gave me a authorization error so I substituted:

    http://www.ijg.org/files/jpegsrc.v6b.tar.gz

    And the forces of goodness and niceness triumph once again.

  8. sweeeeeeeet! 11 days later:

    Nice work.

  9. rebo 12 days later:

    Can I just say many thanks for this, this is one of the few multi install scripts that I have used that have worked right off of the bat.

    Nice one!

  10. Nick 13 days later:

    Thanks a lot for this script — this was my first time installing RMagick and it went very smoothly (after fixing the URLs for the JPEG and Ghostscript fonts downloads). From what I read online about installing RMagick, you just saved me A LOT of time. Thanks!

  11. Tim 13 days later:

    Got everything installed…. Rmagick shows in my gems, but when I require ‘remagick’ I get “no such file to load — rmagick”. Any thoughts from anyone reading this?

  12. Lee 13 days later:

    @Tim: you need to require ‘RMagick’, notice the capitalization

  13. Tim 13 days later:

    @Lee: I previously tried that too… Here is my interaction in irb.

    irb(main):001:0> require ‘RMagick’
    LoadError: no such file to load — RMagick
         from (irb):1:in `require’
         from (irb):1
    irb(main):002:0>

  14. Josh 13 days later:

    awesome. nice work. took like 20 minutes on my 2GHz macbook, but seems to have worked…

  15. Tim 13 days later:

    Even after make uninstalling and retrying I wasn’t successful. While I never got an error I could not require RMagick into Ruby… I did a bit of searching and found that is a Ruby script that came out on 11/4/07 on RubyForge that worked perfectly. It automatically downloads everything you need and worked awesome:

    http://rubyforge.org/frs/?group_id=12&release_id=16101

  16. Gravitas 16 days later:

    SetupRailsonLeopard. I just completed my Rails setup, thanks Tim you rock, this is the quick rundown on it.

  17. jm 17 days later:

    A good link to compile wget once and for all on leopard :
    http://radio.javaranch.com/bear/2005/03/02/1109829480523.html

    Thanks for this script !

  18. kematzy 20 days later:

    Thanks a lot!! Worked a treat apart from the URL issues which were commented about above.

  19. Simon Plenderleith 26 days later:

    Dude… you are an absolute saviour! I’ve been going crazy trying to get ImageMagick working as I want it in Leopard. I changed the URLs as required and it worked great.

    Thank you so much!

  20. Markus Arike 28 days later:

    I had great success with the rm_install.rb script that is available at RubyForge’s RMagick http://rmagick.rubyforge.org/ page . It automates the process, much like the above script, but seems to do more clean up, error handling, etc. After trying to get it working on OSX for so long, to no avail, I finally have it. It’s good day.

  21. Patrick about 1 month later:

    thanks so much, worked like a champ.

  22. Robert Aganauskas about 1 month later:

    @Tim: you have to require rubygems before rmagick i.e.


    irb(main):001:0> require ‘rubygems’
    => true
    irb(main):002:0> require ‘RMagick’
    => true

  23. Dave Frey 3 months later:

    Excellent, thanks a lot.

    Your ImageMagick link was broken for me, but I found another here:
    http://ftp.surfnet.nl/pub/ImageMagick/ImageMagick-6.3.5-9.tar.gz

  24. Justin Grevich 4 months later:

    @Tim

    You may also need to require ‘rubygems’ before requiring RMagick in irb (depending if you are using an .irbrc or not). Somehow my OS X install of Ruby auto-installed an .irbrc for me. I posted an example of it here: http://pastie.org/158471

    Hope that helps,

    justin

  25. Peter 4 months later:

    hmmm, when i follow this guide, i eventually get this at the end (after gem install RMagick):
    ERROR: could not find RMagick locally or in a repository

    any ideas/

  26. Adam 4 months later:

    @Peter: If you didn’t figure this out already, the gem is in fact called ‘rmagick’, so “sudo gem install rmagick” should work for you.

  27. Julie 4 months later:

    there was a problem with both ghostscript ftps, so I substituted:

    wget http://ufpr.dl.sourceforge.net/sourceforge/ghostscript/ghostscript-8.60.tar.gz

    and

    wget http://ufpr.dl.sourceforge.net/sourceforge/ghostscript/ghostscript-fonts-std-8.11.tar.gz

  28. nick 5 months later:

    Thank you very much! Everything worked! :)

  29. Lance Carlson 6 months later:

    I think it’s sudo gem install rmagick not RMagick. Otherwise everything worked pretty well with the urls from Julie.

  30. Huy Tong 6 months later:

    Nice script. I did the steps and it didn’t work on my end. Something about the headers. I’m trying the OSX installer now provided on the forge, I think it pretty much does what your script does but I’ll wait and see.

  31. D. Starr 7 months later:

    Hi, I’m just wondering why you didn’t compile Ghostscript as a framework (which seems to be the recommended way) and if you’ve tested that your IM can actually call GS to delegate vector formats.

  32. Bob F. 9 months later:

    This worked pretty well on a brand new Leopard system. I used curl and adjusted some URLs, as mentioned by others already.

    I’d like to point out two problems:

    1. It’s important you build a later version of libpng, as there’s a vulnerability in the version given here.
    2. If you see this error during the installation phase of the jpeg “/usr/local/man/man1/cjpeg.1: No such file or directory” it just indicates that the directory /usr/local/man/man1 doesn’t exist and you need to create it before running the install.

    Thanks for putting this together… it saved me a ton of headaches.

  33. Jeffrey Krause 9 months later:

    Here is the latest modified version which worked for me on a new leopard install, new links, new versions, etc:

    #!/bin/sh
    curl -O http://download.savannah.gnu.org/releases/freetype/freetype-2.3.7.tar.gz
    tar xzvf freetype-2.3.7.tar.gz
    cd freetype-2.3.7
    ./configure --prefix=/usr/local
    make
    sudo make install
    cd ..
    
    curl -O http://superb-west.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.29.tar.bz2
    tar jxvf libpng-1.2.29.tar.bz2
    cd libpng-1.2.29
    ./configure --prefix=/usr/local
    make
    sudo make install
    cd ..
    
    curl -O http://quirkysoft.googlecode.com/files/jpegsrc.v6b.tar.gz
    tar xzvf jpegsrc.v6b.tar.gz
    cd jpeg-6b
    ln -s `which glibtool` ./libtool
    export MACOSX_DEPLOYMENT_TARGET=10.5.4
    ./configure --enable-shared --prefix=/usr/local
    make
    sudo mkdir /usr/local/man/man1
    sudo make install
    cd ..
    
    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 ..
    
    curl -O http://voxel.dl.sourceforge.net/sourceforge/wvware/libwmf-0.2.8.4.tar.gz
    tar xzvf libwmf-0.2.8.4.tar.gz
    cd libwmf-0.2.8.4
    make clean
    ./configure
    make
    sudo make install
    cd ..
    
    curl -O http://www.littlecms.com/lcms-1.17.tar.gz
    tar xzvf lcms-1.17.tar.gz
    cd lcms-1.17
    make clean
    ./configure
    make
    sudo make install
    cd ..
    
    curl -O ftp://mirror.cs.wisc.edu/pub/mirrors/ghost/GPL/gs860/ghostscript-8.60.tar.gz
    tar zxvf ghostscript-8.60.tar.gz
    cd ghostscript-8.60/
    ./configure  --prefix=/usr/local
    make
    sudo make install
    cd ..
    
    curl -O ftp.yzu.edu.tw/mirror/pub1/Unix/Tex/CTAN/support/ghostscript/GPL/gs815/ghostscript-fonts-std-8.11.tar.gz
    tar zxvf ghostscript-fonts-std-8.11.tar.gz
    sudo mv fonts /usr/local/share/ghostscript
    
    curl -O ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-6.4.2-6.tar.gz
    tar xzvf ImageMagick-6.4.2-6.tar.gz
    cd ImageMagick-6.4.2
    export CPPFLAGS=-I/usr/local/include
    export LDFLAGS=-L/usr/local/lib
    ./configure --prefix=/usr/local --disable-static --with-modules --without-perl --without-magick-plus-plus --with-quantum-depth=8 --with-gs-font-dir=/usr/local/share/ghostscript/fonts
    make
    sudo make install
    cd ..
    
    sudo gem install rmagick
    
  34. Web Design Preston 10 months later:

    Thanks to Julie for the URL’s. Saved me a heap of time.

  35. Cary 10 months later:

    Thank you! Saved alot of time.

  36. Kyle 11 months later:

    Thanks for this; saved me a bit of headache.

    As of Sep 30, 2008, here’s an updated version using curl and with 100% valid urls.

    http://pastie.org/282226

  37. b 11 months later:

    when i try to install libwmf, and run the “make” command, I get the following error:

    make: * No rule to make target `clean’. Stop.

    Is this some incompatibility with my compiler, and is the “clean” part needed (what does it do)?

  38. manuel about 1 year later:

    Hi.
    I install with this step but when try executing my web aplication in ruby on rails say this:

    no such file to load — RMagick

    I test with this:
    irb(main):001:0> require ‘rubygems’
    => true
    irb(main):002:0> require ‘rmagick’
    => true

    any idea? please.
    thanks.

  39. Sven about 1 year later:

    I’m not such a big fan of Fink (too outdated) and MacPorts (awfully poor dependency handling) either. But as my servers are running smoothly on Gentoo for years now, I’ve chosen Gentoo Prefix as my distro of choice for the Mac, too. Here’s more on how I did it:

    http://www.bitcetera.com/en/tecblog/2008/05/08/gentoo-prefix-on-mac-os-x/

  40. Sven about 1 year later:

    I’m not such a big fan of Fink (too outdated) and MacPorts (awfully poor dependency handling) either. But as my servers are running smoothly on Gentoo for years now, I’ve chosen Gentoo Prefix as my distro of choice for the Mac, too. Here’s more on how I did it:

    http://www.bitcetera.com/en/tecblog/2008/05/08/gentoo-prefix-on-mac-os-x/

  41. tilthouse about 1 year later:

    Awesome… Best native OSX ImageMagick build instructions I’ve seen yet. Still works with the latest version of each library / prerequisite substituted in.

  42. D about 1 year later:

    I’m also getting the error:

    make: * No rule to make target `clean’. Stop.

    b, did you get around this?

  43. Paul about 1 year later:

    I’m running the script now, and i’m freaked out, because it’s dropping files all over my home directory and it’s ruining my shiny new macbook pro… is this normal?

    HELP!!!… I don’t really know much about UNIX

  44. Russell about 1 year later:

    OSX 10.5.5
    Amazingly, after an hour of grinding away, on the final step I get:

    gcc -I. -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin9.0 -I/Users/rjbalest/Desktop/rm_install_tmp/RMagick-2.9.0/ext/RMagick -DRUBY_EXTCONF_H=\“extconf.h\” -I/usr/local/include/ImageMagick -fno-common -I/usr/local/include/ImageMagick -c rmimage.c
    rmimage.c: In function ‘Image_delay’:
    rmimage.c:3428: error: ‘C_unsigned’ undeclared (first use in this function)
    rmimage.c:3428: error: (Each undeclared identifier is reported only once
    rmimage.c:3428: error: for each function it appears in.)
    rmimage.c:3428: error: syntax error before ‘long_to_R_unsigned’
    rmimage.c: In function ‘Image_delay_eq’:
    rmimage.c:3428: error: ‘R_unsigned’ undeclared (first use in this function)
    rmimage.c:3428: error: syntax error before ‘long_to_C_unsigned’
    make: * [rmimage.o] Error 1

    I’m googling like mad but can’t find a solution yet. Any help?

  45. Russell about 1 year later:

    I see. The preprocessor is turning ulong into unsigned long in the statements like:

    ATTR_ACCESSOR(Image, foo ,ulong)

    Which is bad.

  46. jonfredgeekadams.blogspot.com over 1 year later:

    The first line didn’t work for me. I used:
    curl -O http://www.very-clever.com/download/nongnu/freetype/freetype-2.3.5.tar.gz
    instead.

  47. m3talsmith over 1 year later:

    This works fine for me everytime:

    http://www.imagemagick.org/script/install-source.php

  48. Manik over 1 year later:

    Awesome! All set with Rmagick on my new MBP.

  49. Lee over 1 year later:

    Awesome! RMagick is installed successfully. Save me a lot of time. Thank you very much for the post!

  50. Jimmy Baker over 1 year later:

    I have to download the ghostscript files from http://code.google.com/p/ghostscript/downloads/detail?name=ghostscript-8.60.tar.gz&can=2&q=
    and
    http://code.google.com/p/ghostscript/downloads/detail?name=ghostscript-fonts-std-8.11.tar.gz&can=2&q=

  51. http://www.cornicescentre.co.uk over 1 year later:

    I’m running the script now, and i’m freaked out, because it’s dropping files all over my home directory and it’s ruining my shiny new macbook pro… is this normal?

  52. Ashok over 1 year later:

    Solomon and Kyle (who wrote version with updated urls)

    YOU GUYS ROCK!!!!

    Thank you