I like Ubuntu Server. I really like apt-get
, because I don’t have to do any work at all to install stuff. It’s a piece of cake.
Unfortunately, sometimes installing using apt-get
doesn’t work, or maybe the software I need isn’t the latest and greatest version on the Ubuntu repository. In such cases, there’s only one option left: installing from source.
That means downloading, extracting, configuring, building, debugging, etc. Most people shy away from doing this because it isn’t fast and easy, and stuff can break.
I recently had the opportunity to install the latest version of ImageMagick on an Ubuntu server, and it was a lot easier than I thought it would be!
Here’s how you do it…
First, keep in mind that almost all software you compile and install has dependencies. Since we’re not using apt-get, you might have to do a little sleuthing and figure out how to install the packages for the necessary dependencies. Fortunately, you can normally just use apt-get for this stuff, and then recompile, and you’re off and running.
Still, this is not a one-size-fits-all solution, and it is not guaranteed to work for you. It really depends on what you have on your system already, what server version you have, etc. So, having said all that, try this:
1. sudo apt-get update
This makes sure we’re gonna get the latest and greatest packages
2. sudo apt-get install build-essential
This ensures you have tools like g++, gcc, make, etc. so you can actually compile ImageMagick
3. sudo apt-get install imagemagick
No, I haven’t lost my mind. This makes sure that you have a whole bunch of dependencies installed without having to manually figure them all out and install them individually. But it still might not give you the latest-and-greatest version of imagemagick, which is why we need to do the install from source!
4. Download the latest version of ImageMagick. You could just do:
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
5. tar xvfz ImageMagick.tar.gz
Extracts the files
6. cd ImageMagick-6.X.X-X
Change into the directory containing the extracted files
7. ./configure --prefix=/usr
This runs the configure script. With the “prefix” option, you are telling it to install files in /usr instead of the default /usr/local directory. Otherwise, Ubuntu will complain.
NOTE: If you’re getting the Rails error “RMagick was compiled with ImageMagick X.X.X, but Y.Y.Y is installed”, leave off the “–prefix=/usr” part and try again. Then reinstall RMagick. That should do the trick. This is especially annoying on Ubuntu 11.04 and above!
8. make
Build ImageMagick
9. make install
Install ImageMagick
10. identify -version
This should display the proper version of ImageMagick
NOTE: If you get an error like “error while loading shared libraries” when you run the above command, type this:
ldconfig /usr/local/lib
11. identify -list format
This should list the file formats that ImageMagick can process. If anything is missing, you’ll have to install it and recompile
That’s it!
Steps 7, 8, and 9 might take awhile. But now you can install things like RMagick and other toys that use ImageMagick.
If you run into any trouble, Google is your friend. Also, you can read the Advanced ImageMagick Install instructions.
Hi, ins’t –prefix=/usr instead of –opt ?
Thanks,
Peter
@Peter
Oops! Yup, you’re right. I fixed it. Thanks!!
On an older version of Ubuntu (8.04.2), I found I also needed to update my JPEG- and PNG-processing libraries, else my nice new ImageMagick bungled operations on JPEG and PNG files. If you’re having trouble with these file types, try
sudo apt-get install libjpeg62-dev libpng12-dev
followed by rebuilding and reinstalling ImageMagick (step 7 onward).
i am running ubuntu 11.10 .I install the source from http://www.imagemagick.org/download/ImageMagick-6.7.6-4.7z
when i want to convert the image to pdf i get the following error.
convert: no decode delegate for this image format `a.JPG’ @ error/constitute.c/ReadImage/533.
convert: missing an image filename `a.PDF’ @ error/convert.c/ConvertImageCommand/3017.
Please help
The message “no decode delegate for this image format” means that imagemagick needs the proper library in Ubuntu in order to process the image type – in this case, JPG.
On 11.10, you should be able to do:
apt-get install libjpeg62 libpng12-0
Then you’ll need to recompile imagemagick.
Then when you type this:
identify -list configure
It should show you under LIBS that you have “ljpeg” and “lpng12” installed, which should fix your error message – and allow processing of PNG image files, as well.
cool, thanks to this post, i managed to install rmagick on an old ubuntu box. thx !!!
I think you can use the following to install dependencies without installing the package:
apt-get build-dep imagemagick
Not working ..
Building native extensions. This could take a while…
ERROR: Error installing rmagick:
ERROR: Failed to build gem native extension.
/usr/bin/ruby1.9.1 extconf.rb
checking for gcc… yes
checking for Magick-config… no
checking for pkg-config… yes
Warning: Found a partial ImageMagick installation. Your operating system likely has some built-in ImageMagick libraries but not all of ImageMagick. This will most likely cause problems at both compile and runtime.
Found partial installation at: /usr
checking for outdated ImageMagick version (= 6.9.0)… no
checking for Ruby version >= 1.8.5… yes
checking for stdint.h… yes
checking for sys/types.h… yes
checking for wand/MagickWand.h… no
Can’t install RMagick 2.16.0. Can’t find MagickWand.h.
*** 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.
Provided configuration options:
–with-opt-dir
–without-opt-dir
–with-opt-include
–without-opt-include=${opt-dir}/include
–with-opt-lib
–without-opt-lib=${opt-dir}/lib
–with-make-prog
–without-make-prog
–srcdir=.
–curdir
–ruby=/usr/bin/ruby1.9.1
Gem files will remain installed in /var/lib/gems/1.9.1/gems/rmagick-2.16.0 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/rmagick-2.16.0/ext/RMagick/gem_make.out
Ooo! This is a really old post (2010). Usually, nowadays I just install from the Ubuntu repos and it works fine.
But that usually means I have to do:
sudo apt-get install imagemagick libmagickwand-dev
Then I do:
gem install rmagick
Usually, that works… I also always use the latest Ruby, which I install from source.