Linux – Can’t install Image::Magick, even though Image Magick is installed

imagemagicklinuxperl

I'm trying to work out why Image::Magick won't install. I've tried loads of things, but it still fatals:

perl -MCPAN -e 'install Image::Magick'

…and it dies with:

Reading '/root/.cpan/sources/modules/03modlist.data.gz'
DONE
Writing /root/.cpan/Metadata
Running install for module 'Image::Magick'
Fetching with LWP:
http://www.cpan.org/authors/id/J/JC/JCRISTY/PerlMagick-6.89-1.tar.gz
Fetching with LWP:
http://www.cpan.org/authors/id/J/JC/JCRISTY/CHECKSUMS
Checksum for /root/.cpan/sources/authors/id/J/JC/JCRISTY/PerlMagick-6.89-1.tar.gz ok
'YAML' not installed, will not store persistent state
Configuring J/JC/JCRISTY/PerlMagick-6.89-1.tar.gz with Makefile.PL
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for Image::Magick
Writing MYMETA.yml and MYMETA.json
  JCRISTY/PerlMagick-6.89-1.tar.gz
  /usr/bin/perl Makefile.PL INSTALLDIRS=site -- OK
Running make for J/JC/JCRISTY/PerlMagick-6.89-1.tar.gz
cp Magick.pm blib/lib/Image/Magick.pm
AutoSplitting blib/lib/Image/Magick.pm (blib/lib/auto/Image/Magick)
Running Mkbootstrap for Image::Magick ()
chmod 644 "Magick.bs"
"/usr/bin/perl" "/usr/share/perl/5.22/ExtUtils/xsubpp"  -typemap "/usr/share/perl/5.22/ExtUtils/typemap" -typemap "typemap"  Magick.xs > Magick.xsc && mv Magick.xsc Magick.c
x86_64-linux-gnu-gcc -c  -I/usr/local/include/ImageMagick-6 -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/libxml2 -I"/usr/include/ImageMagick-6" -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fwrapv -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/freetype2 -g -O2 -Wall -pthread -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -O2 -g   -DVERSION=\"6.89\" -DXS_VERSION=\"6.89\" -fPIC "-I/usr/lib/x86_64-linux-gnu/perl/5.22/CORE"  -D_LARGE_FILES=1 -DHAVE_CONFIG_H Magick.c
In file included from /usr/include/ImageMagick-6/magick/MagickCore.h:29:0,
                 from Magick.xs:60:
/usr/include/ImageMagick-6/magick/magick-config.h:21:38: fatal error: magick/magick-baseconfig.h: No such file or directory
compilation terminated.
Makefile:350: recipe for target 'Magick.o' failed
make: *** [Magick.o] Error 1
  JCRISTY/PerlMagick-6.89-1.tar.gz
  /usr/bin/make -- NOT OK

The thing is, it does seem to exist:

root@admin:~# locate magick-baseconfig.h
/usr/include/x86_64-linux-gnu/ImageMagick-6/magick/magick-baseconfig.h

Any ideas as to what to try? I've tried just doing:

apt-get install libmagickcore-dev

.. but no joy.

Best Answer

My recommendation would be to avoid installing modules from source with CPAN when your distribution also provides them as normal packages. Using the normal packages allows you to benefit from the dependancy management, regular security updates and security fixes your distribution provides and it is much more consistent for your configuration management.

For Debian and Ubuntu that would be the libimage-magick-perl package (for RHEL CentOS the equivalent is ImageMagick-perl)

apt-get install libimage-magick-perl