Demnogonis Demnogonis - 4 months ago 20
Perl Question

Image::Magick on Strawberry Perl 5.12

I am trying to install

Image::Magick
on Strawberry Perl 5.12 on Windows XP, but it doesn't find the ImageMagick modules when it generates the makefile. The make also throws lots of compiler errors.

I did exactly what is written in the readme of Image::Magic:

Installation - Win32 Strawberry perl

On Win32 Strawberry Perl the preferred way of installing PerlMagick is the
following:

1) Download and install ImageMagick Windows binaries from
http://www.imagemagick.org/script/binary-releases.php#windows

2) You HAVE TO choose dynamic (DLL) ImageMagick binaries. Note: it is not
possible to mix 32/64bit binaries of Perl and ImageMagick

3) During installation select that you want to install ImageMagick's
development files (libraries+headers)

4) You NEED TO have ImageMagick's directory in your PATH. Note: we are
checking the presence of convert.exe or identify.exe tools

5) You might need Visual C++ Redistributable Package installed on your
system. See instructions on ImageMagick's Binary Release webpage.

6) If you have all prerequisites 1)...5) you can simply install
ImageMagick by running: cpan -i Image::Magick


And I am getting this:

################################### WARNING! ###################################
# It seems that you are trying to install Perl::Magick on a MS Windows box with
# perl + gcc compiler (e.g. Strawberry Perl), however we cannot find ImageMagick
# binaries installed on your system.
#
# Please check the following prerequisites:
#
# 1) You need to have installed ImageMagick Windows binaries from
# http://www.imagemagick.org/script/binary-releases.php#windows
#
# 2) We only support dynamic (DLL) ImageMagick binaries
# note: it is not possible to mix 32/64-bit binaries of perl and ImageMagick
#
# 3) During installation select that you want to install ImageMagick's
# development files (libraries+headers)
#
# 4) You also need to have ImageMagick's directory in your PATH
# note: we are checking the presence of convert.exe and/or identify.exe tools
#
# 5) You might need Visual C++ Redistributable Package installed on your system
# see instructions on ImageMagick's Binary Release webpage
#
# We are gonna continue, but chances for successful build are very low!
################################################################################
Note (probably harmless): No library found for -lMagickCore
Note (probably harmless): No library found for -lmoldname
Note (probably harmless): No library found for -lkernel32
Note (probably harmless): No library found for -luser32
Note (probably harmless): No library found for -lgdi32
Note (probably harmless): No library found for -lwinspool
Note (probably harmless): No library found for -lcomdlg32
Note (probably harmless): No library found for -ladvapi32
Note (probably harmless): No library found for -lshell32
Note (probably harmless): No library found for -lole32
Note (probably harmless): No library found for -loleaut32
Note (probably harmless): No library found for -lnetapi32
Note (probably harmless): No library found for -luuid
Note (probably harmless): No library found for -lws2_32
Note (probably harmless): No library found for -lmpr
Note (probably harmless): No library found for -lwinmm
Note (probably harmless): No library found for -lversion
Note (probably harmless): No library found for -lodbc32
Note (probably harmless): No library found for -lodbccp32
Note (probably harmless): No library found for -lcomctl32
Writing Makefile for Image::Magick
Writing MYMETA.yml and MYMETA.json


But the ImageMagick binaries are installed and in the path variable.

How do I to get this to run?

Answer

I got a solution!

The problem is, that the Makefile.pl looks for the binaries in the wrong directories.

  1. Get the latest ImageMagick package. click
  2. Unzip it and navigate into the PerlMagick folder
  3. open Makefile.pl in an editor.
  4. Take a look at the first foreach block:

foreach my $line (split '\n', $conf) {

if ($line =~ /^Path:\s+(.*)/) {
  my ($vol,$dir,$file) = splitpath($1);
  next unless $dir;
  my $dirpath = catpath( $vol, $dir);
  my (@l,@b,@i) = ( (),(),() );

  # try to detect 'lib' dir
  push @l, catfile($dirpath,'..','lib');
  push @l, catfile($dirpath,'..','..','lib');
  push @l, catfile($dirpath,'..','..','..','lib');
  foreach (@l) { push @libdir, $_ if (-d $_) };

  # try to detect 'bin' dir
  push @b, catfile($dirpath,'..');
  push @b, catfile($dirpath,'..','bin');
  push @b, catfile($dirpath,'..','..');
  push @b, catfile($dirpath,'..','..','bin');
  push @b, catfile($dirpath,'..','..','..');
  push @b, catfile($dirpath,'..','..','..','bin');
  foreach (@b) { push @bindir, $_ if (-e "$_/convert.exe" || -e "$_/identify.exe") };

  # try to detect 'include' dir
  push @i, catfile($dirpath,'..','include');
  push @i, catfile($dirpath,'..','include','ImageMagick');
  push @i, catfile($dirpath,'..','..','include');
  push @i, catfile($dirpath,'..','..','include','ImageMagick');
  push @i, catfile($dirpath,'..','..','..','include');
  push @i, catfile($dirpath,'..','..','..','include','ImageMagick');
  foreach (@i) { push @incdir, $_ if (-e "$_/magick/MagickCore.h") };
}

}

The script gets the location of the IM installation from the %PATH% and looks for the bin, lib and include folders. It looks everywhere except at its actual location.

So you just need to add these:

# try to detect 'lib' dir
push @l, catfile($dirpath,'lib');
...
# try to detect 'bin' dir
push @b, catfile($dirpath);
...
# try to detect 'include' dir
push @i, catfile($dirpath,'include');
...

After that you can execute perl Makefile.pl and it will correctly generate the makefile. Then just say dmake and dmake install and you will be fine.

I hope that helps somebody sometime.

Comments