Compile Imagemagick for Rmagick 2.0 gem
Posted by Vince Wadhwani on Jan 22, 2008
If you've updated your gems recently you may have noticed that the latest rmagick isn't working. I've run into this problem on Feisty, Gutsy, and Debian Sid. The culprit is a version of Imagemagick older than 6.3.0. The Rmagick gem used to work with Graphicmagick so I'm not entirely sure why it refuses to install, but I get an error that says:
Can't install RMagick 2.0.0. You must have ImageMagick 6.3.0 or later. *** extconf.rb failed *** Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/rmagick-2.1.0 for inspection. Results logged to /usr/lib/ruby/gems/1.8/gems/rmagick-2.1.0/ext/RMagick/gem_make.out
Bleh. In order to get around this, you'll have to compile Imagemagick from source. Here's how I did it (the somewhat painless way)
First thing you want to do is get rid of any installed older packages:
sudo apt-get remove imagemagick sudo apt-get remove graphicsmagick
Next, grab the packages you'll need to install Imagemagick:
sudo apt-get install build-essential sudo apt-get build-dep imagemagick
One more install to make sure you got everything:
sudo apt-get install gcc libjpeg62-dev libbz2-dev libtiff4-dev libwmf-dev libz-dev libpng12-dev libx11-dev libxt-dev libxext-dev libxml2-dev libfreetype6-dev liblcms1-dev libexif-dev perl libjasper-dev libltdl3-dev graphviz gs-gpl pkg-config
Next grab the latest source for Imagemagick from the FTP server nearest you.
wget ftp://ftp.fifi.org/pub/ImageMagick/ImageMagick-6.3.8-0.tar.gz tar xvzf ImageMagick-6.3.8-0.tar.gz
Let's build that sucker:
cd ImageMagick-6.3.8/ ./configure
You should make sure when you run ./configure that support is there for JPEG v1, JPEG-2000, PNG, and ZLIB at a minimum.. If so, then continue on.
make sudo make install
With that done, let's try to install rmagick again:
sudo gem install rmagick
Hopefully you'll see output along these lines:
vince@redplume:~/ImageMagick-6.3.8$ sudo gem install rmagick Building native extensions. This could take a while... Successfully installed rmagick-2.1.0 1 gem installed
Further troubleshooting: To confirm that Imagemagick is installed correctly after being compiled, run:
identify -list format
If instead of a listing of formats Imagemagick can handle, you get an error like "libMagick.so.10: cannot open shared object file" it means that one of your library paths did not get properly used during the installation. What you'll need to do is make sure /usr/local/lib is in your /etc/ld.so.conf/libc6.conf file. Assuming it is (if not, add it) run:
sudo ldconfig
After that, uninstall Imagemagick and the Rmagick gem and then reinstall them again.
And with that.. you're done!
Update: Or are you? For some reason I can't get rmagick to resize images on Gutsy even though it works on Debian. Next up installing ImageScience on Ubuntu.
Nice tutorial! This page probably will answer some of your questions: http://rmagick.rubyforge.org/rmagick2.html. Next time you have questions drop me a line. I’ll be glad to help.
Tim Hunter
It worked for me ! Thanks.
philippe
If like me, your feeling a bit lazy (i.e. no time), you might find it easier to force the previous version of rmagick:
gem install rmagick -v “1.15.12”
That worked well for me and saved going through each step of this very clear tutorial.
Cheers, sam
Sam Lown
@Tim, Thanks for the link - it did answer some of my questions!
@philippe, glad it worked for you!
@Sam, You know it’s weird but even backing down to v1.15.12 didn’t work for me on my Gutsy server w/ Rails 2.0.2. I figured that a newer Rmagick was required which is why I went through all of this to begin with but your success with the older version makes me think that my trouble is with the ImageMagick install and not with the Rmagick gem (which is 2.1 not 2.0 as I stated in the article title..)
vince
Hey, thanks for the notes. I’m trying to get latest versions of ImageMagick/Rmagick on debian/etch; your notes seemed to be the solution, but I’m still stuck on:
LoadError: libWand.so.10: cannot open shared object file: No such file or directory - /var/lib/gems/1.8/gems/rmagick-2.2.0/lib/RMagick2.so
Can you recommend a next step?
Shinji Kuwayama
Brilliant! Worked perfectly thanks.
Debian sarge 4.0
James