mikeraz has asked for the wisdom of the Perl Monks concerning the following question:

hullo, Attempting a fresh installaiton of Image::Magick from cpan.

retrieve PerlMagick-6.20 - no problem
perl Makefile.PL
Checking if your kit is complete...
Looks good
Note (probably harmless): No library found for -llcms
Writing Makefile for Image::Magick
This seems OK to me

make
cp Magick.pm blib/lib/Image/Magick.pm
AutoSplitting blib/lib/Image/Magick.pm
(blib/lib/auto/Image/Magick)
...
gcc -c -I../ -I.. -I/usr/include/freetype2 ...
Magick.xs:63:24: magick/api.h: No such file or directory

Well that's fatal.

some Google searching leads to an impression that one needs to install from source, as in a full ImageMagick install from source.

Is there a better way?

  • Comment on Image::Magick install failure - no magick/api.h

Replies are listed 'Best First'.
Re: Image::Magick install failure - no magick/api.h
by Fletch (Bishop) on May 21, 2005 at 14:29 UTC

    Depending on your OS there may be a separate development package (for example on RedHat for foo-x.y.rpm it'd be foo-devel-x.y.rpm) which has things like headers and static copies of libraries (.a). Try to install that (and/or talk nice to your sysadmin).

      Well, I told my lazy sysadmin to get off his butt and just do the Image Magick source install. Since I'm the lazy sysadmin in question, I went ahead and did it. Everything worked fine after that point. Where "everything" means I installed the Perlmagick from the source that came with ImageMagick rather than from the cpan available archive.

      It seems the cpan archive for Image Magick is broken, becuase it doesn't contain a set of files necessary for a sucessful install.

      Thanks for the response.

        See http://search.cpan.org/src/JCRISTY/PerlMagick-6.20/README.txt
        Introduction 
        
            PerlMagick, is an objected-oriented Perl interface to ImageMagick.
            Use the module to read, manipulate, or write an image or image sequence
            from within a Perl script. This makes it suitable for Web CGI scripts. You
            must have ImageMagick 6.0.2 or above installed on your system for this
            module to work properly.
        
            See
        
                http://www.imagemagick.org/www/perl.html
        
            for additional information about PerlMagick.  See
        
                http://www.imagemagick.org/
        
            for instructions about installing ImageMagick.
        
        
        Installation 
        
            Get the PerlMagick distribution and type the following: 
        
                gunzip ImageMagick-6.0.2-2.tar.gz
                tar xvf ImageMagick-6.0.2
        
            Follow the ImageMagick installation instructions in INSTALL-unix.txt
        		then type
        
              cd PerlMagick
        
            Next, edit Makefile.PL and change LIBS and INC to include the appropriate
            path information to the required libMagick library. You will also need
            library search paths (-L) to JPEG, PNG, TIFF, etc. libraries if they were
            included with your installed version of ImageMagick. If an extension
            library is built as a shared library but not installed in the system's
            default library search path, you may need to add run-path information
            (often -R or -rpath) corresponding to the equivalent library search
            path option so that the library can be located at run-time.
        
            To create and install the dymamically-loaded version of PerlMagick
            (the preferred way), execute
                
                perl Makefile.PL
                make
                make install
        
            To create and install a new 'perl' executable (replacing your existing
            PERL interpreter!) with PerlMagick statically linked (but other libraries
            linked statically or dynamically according to system linker default),
            execute
        
                perl Makefile.PL
                make perl
                make -f Makefile.aperl inst_perl
        	
            or to create and install a new PERL interpreter with a different name
            than 'perl' (e.g. 'PerlMagick') and with PerlMagick statically linked
        
                perl Makefile.PL MAP_TARGET=PerlMagick
                make PerlMagick
                make -f Makefile.aperl inst_perl
        
            See the ExtUtils::MakeMaker(3) manual page for more information on
            building PERL extensions (like PerlMagick).
        
            For Windows systems, type
        
                perl Makefile.nt
                nmake install
        
            For Unix, you typically need to be root to install the software.
            There are ways around this.  Consult the Perl manual pages for more
            information. You are now ready to utilize the PerlMagick routines from
            within your Perl scripts.
        
        
        Testing PerlMagick
        
            Before PerlMagick is installed, you may want to execute
            
                make test
        
            to verify that PERL can load the PerlMagick extension ok.  Chances are
        
            some of the tests will fail if you do not have the proper delegates
            installed for formats like JPEG, TIFF, etc.
        
            To see a number of PerlMagick demonstration scripts, type
            
                cd demo
                make
        
        
        Example Perl Magick Script 
        
            Here is an example script to get you started: 
        
                #!/usr/bin/perl
                use Image::Magick;
        
                $q = Image::Magick->new;
                $x = $q->Read("model.gif", "logo.gif", "rose.gif");
                warn "$x" if $x;
        
                $x = $q->Crop(geom=>'100x100+100+100');
                warn "$x" if $x;
        
                $x = $q->Write("x.gif");
                warn "$x" if $x;
        
            The script reads three images, crops them, and writes a single image
            as a GIF animation sequence.
        
Re: Image::Magick install failure - no magick/api.h
by djohnston (Monk) on May 21, 2005 at 18:03 UTC
    I had similar trouble installing the Image::Magick Perl module a few months ago, and it seems that we've both stumbled upon the same advice via google. It is accurate advice though, as I have succeeded in installing it only by downloading the tarball and compiling from source. The effort paid off big time too, because it's now way faster than the sub-optimal preinstalled version I was stuck with before.
Re: Image::Magick install failure - no magick/api.h
by godzirra (Acolyte) on May 21, 2005 at 21:39 UTC
    I had this exact same problem on gentoo and ended up installing it with the gentoo package. I know if you download the actual source from www.imagemagick.org, you can get the magick/api.h from that source file and then use it to compile your code.
    Godzirra! Destroying Neo Tokyo since 1954