Win32 binaries & strawberry perl

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Locked
kmx

Win32 binaries & strawberry perl

Post by kmx »

Hi,

I have tried to install Image::Magick module on win32/strawberry perl using official ImageMagick Win32 binaries.

The good news is that it is feasible, however there are some gotchas that can make it quite difficult for an inexperienced user.

(1) I have used ImageMagick-6.5.6-9-Q16-windows-dll.exe

This pack includes also a development files but only for Microsoft compiler. (Un)fortunately strawberry perl uses MINGW compiler (gcc for win32). To be able to use official Windows binaries it was necessary to create mingw-compatible import libraries (*.a) - to do this it was necessary:

Code: Select all

cd d:\ImageMagick-6.5.6-Q16\lib 
pexports ..\CORE_RL_magick_.dll > libMagickCore.def
dlltool -D CORE_RL_magick_.dll -l libMagickCore.a -d libMagickCore.def
del libMagickCore.def
pexports ..\CORE_RL_wand_.dll > libMagickWand.def
dlltool -D CORE_RL_wand_.dll -l libMagickWand.a -d libMagickWand.def
del libMagickWand.def
The output were these new files:
d:\ImageMagick-6.5.6-Q16\lib\libMagickCore.a
d:\ImageMagick-6.5.6-Q16\lib\libMagickWand.a
Question 1: Do you think it would be possible to include also mingw-compatible import libraries (libMagickCore.a + libMagickWand.a) into the official Windows binaries?

(2) After that it was necessary to slightly patch Makefile.pl in order to use proper directories with headers (d:\ImageMagick-6.5.6-Q16\include) and libraries (d:\ImageMagick-6.5.6-Q16\lib).

I have just a quick-and-dirty patch at the moment as I do not know what is the proper way to get the information where are ImageMagick's ./lib and ./include directories.

Question 2: What is the right way to get information about ImageMagick's ./lib and ./include directories?
  • is it MAGICK_HOME env variable?
  • can 'identify -list Configure' provide some reasonable hints?
  • or is there another way?
If you provide me with enough information I would be happy to prepare a patch for Makefile.pl that tries to autodetect proper directories where ImageMagick and its dev files are installed.

(3) As you already support Image::Magick for Active Perl instalation it might be also interesting to add an option "install Image::Magick for Strawberry perl" to Windows binaries installer.

My idea is to arrange all things so that the following 3 steps will smoothly work:
  • install strawberry perl
  • install ImageMagick binaries (inc. dev files)
  • simply install Image::Magick by running: cpan Image::Magick
BTW: it would be nice to have the latest Image::Magick on CPAN - currently it is not unfortunately up to date and it is marked as "UNATHORIZED RELEASE" - see http://search.cpan.org/dist/PerlMagick/

--
kmx

User avatar
magick
Site Admin
Posts: 11254
Joined: 2003-05-31T11:32:55-07:00

Re: Win32 binaries & strawberry perl

Post by magick »

Question 1: Do you think it would be possible to include also mingw-compatible import libraries (libMagickCore.a + libMagickWand.a) into the official Windows binaries?
We are completely consumed for at least a year with our things-to-do list. However, if you build us a script that we can run under MinGW to produce a separate distribution that users can download / install for MinGW we will take a closer look at the problem. Our version of MinGW is quite old now. We'll also need instructions on how to keep the MinGW installation up-to-date.

Why is a Windows distribution needed at all? Typically you download the ImageMagick Unix source distribution and type
  • cd ImageMagick-6.5.6-9
    ./configure
    make
    make install
(2) After that it was necessary to slightly patch Makefile.pl in order to use proper directories with headers (d:\ImageMagick-6.5.6-Q16\include) and libraries (d:\ImageMagick-6.5.6-Q16\lib).

I have just a quick-and-dirty patch at the moment as I do not know what is the proper way to get the information where are ImageMagick's ./lib and ./include directories.
We typically use the configure script to set the proper PerlMagick parameters:
  • cd ImageMagick-6.5.6-9
    ./configure
    make
    make install
    cd PerlMagick
    perl Makefile.PL
    make install

kmx

Re: Win32 binaries & strawberry perl

Post by kmx »

magick wrote:We are completely consumed for at least a year with our things-to-do list. However, if you build us a script that we can run under MinGW to produce a separate distribution ...
At the moment I am not proposing a separate mingw distribution - I am just asking to add to files into already existing Win binaries package:
  • libMagickCore.a
  • libMagickWand.a
Those *.a files need not to be compiled they are just "derived" from CORE_RL_magick_.dll and CORE_RL_wand_.dll (as described in my previous post).

The idea was to have one set of DLLs (compiled by MSVC) + two sets of dev libraries 1) *.lib for MSVC; 2) *.a for MINGW.
magick wrote:Why is a Windows distribution needed at all? Typically you download the ImageMagick Unix source distribution and type...
I know, unfortunately win32/strawberry perl packcage includes just gcc, g++, ld, make, binutils and few other utils however not a shell - so running ./configure is not possible.

But if you are absolutely out of time I have one solution I can prepare by myself:
  • It is a "pure-perl-way" (patching just PerlMagick)
  • I can prepare a patch for PerlMagick/Makefile.pl that will try to detect whether it is a Win32 box with gcc compiler and tries to find the installation of standard/official binaries.
  • In the next step I am able to generate necessary libMagickCore.a + libMagickWand.a on the fly (providing that the user has installed DLL version of IM).
  • And if I properly set LDFLAGS and INC params of WriteMakefile() I am able to build the module.
  • It will mean one big "if (($^O eq 'MSWin32') && ($Config{cc} eq 'gcc')) {...}" in Makefile.PL
In the end it will work from user point of view like this:
  • Install Win32 strawberry perl
  • Install ImageMagick Win32 dynamic binaries (choose: install dev file + put IM to PATH)
  • Install: cpan -i Image::Magick
If you will agree with this approach I can prepare a patch for Makefile.pl

--
kmx

User avatar
magick
Site Admin
Posts: 11254
Joined: 2003-05-31T11:32:55-07:00

Re: Win32 binaries & strawberry perl

Post by magick »

Sure, post your patch here and we will get it into the next point release of ImageMagick. Thanks.

kmx

Re: Win32 binaries & strawberry perl

Post by kmx »

magick wrote:Sure, post your patch here and we will get it into the next point release of ImageMagick. Thanks.
Here it is:

Code: Select all

Index: PerlMagick/Makefile.PL
===================================================================
--- PerlMagick/Makefile.PL	(revision 333)
+++ PerlMagick/Makefile.PL	(working copy)
@@ -23,7 +23,105 @@
 
 use ExtUtils::MakeMaker;
 use Config;
+use File::Spec::Functions qw/catfile catdir devnull catpath splitpath/;
+use Cwd;
 
+sub AutodetectWin32gcc {
+  my $wrkdir = getcwd();
+  my $devnull = devnull();
+  
+  my @incdir = ();
+  my @libdir = ($wrkdir);
+  my @bindir = ();
+  
+  #try to get configuration info via identify or convert utilities 
+  my $conf = `identify -list Configure 2>$devnull` || `convert -list Configure 2>$devnull`;
+  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") };
+    }
+  };
+  
+  foreach my $bin (@bindir) { 
+    opendir(my $bindir, $bin) or die qq{Cannot opendir $bin: $!};
+    my @dlls = map {catfile($bin, $_)} grep /^\S*magick[^\+]\S*?\.dll$/i, readdir $bindir;
+    foreach my $d (@dlls) {
+      unlink "$wrkdir/libMagickCore.def", "$wrkdir/libMagickCore.a";
+      system("pexports \"$d\" >\"$wrkdir/libMagickCore.def\" 2>$devnull");
+      open(DEF, "<$wrkdir/libMagickCore.def");
+      my @found = grep(/InitializeMagickResources/, <DEF>); #checking if we have taken the right DLL
+      close(DEF);
+      next unless(@found);
+      print STDERR "Gonna create 'libMagickCore.a' from '$d'\n";
+      system("dlltool -D \"$d\" -d \"$wrkdir/libMagickCore.def\" -l \"$wrkdir/libMagickCore.a\" 2>$devnull");
+      last if -s "$wrkdir/libMagickCore.a";
+    }
+    last if -s "$wrkdir/libMagickCore.a";
+  }
+  
+  unless(@incdir && @libdir && @bindir && (-s "$wrkdir/libMagickCore.a")) {
+    print STDERR <<EOF
+################################### 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!
+################################################################################ 
+EOF
+  } 
+    
+  my $inc = join ' ', map "-I\"$_\"", @incdir;
+  my $lib = join ' ', map "-L\"$_\"", @libdir;
+  $lib .= " -lMagickCore";
+
+  return ($inc, $lib, '-O2');
+}
+
 # Compute test specification
 my $delegate_tests='t/*.t';
 my $delegate;
@@ -39,6 +137,16 @@
   }
 }
 
+# defaults for LIBS & INC & CCFLAGS params that we later pass to Writemakefile
+my $INC_val = '-I../ -I.. -I/usr/include/freetype2 -I/usr/include/libxml2 -I"' . $Config{'usrinc'} . '/ImageMagick"';
+my $LIBS_val = '-L../magick/.libs -lMagickCore -L../wand/.libs -lperl -lm';
+my $CCFLAGS_val = "$Config{'ccflags'} -fopenmp -g -O2 -Wall -W -pthread";
+
+if (($^O eq 'MSWin32') && ($Config{cc} =~ /gcc/)) {
+  # a special setup for strawberry perl
+  ($INC_val, $LIBS_val, $CCFLAGS_val) = AutodetectWin32gcc();
+}
+
 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
 # the contents of the Makefile that is written.
 WriteMakefile
@@ -59,7 +167,7 @@
    'DEFINE'	=> ' -D_LARGE_FILES=1 -DHAVE_CONFIG_H',     # e.g., '-DHAVE_SOMETHING' 
 
    # Header search specfication and preprocessor flags
-   'INC'	=> '-I../ -I.. -I/usr/include/freetype2 -I/usr/include/libxml2 -I"' . $Config{'usrinc'} . '/ImageMagick"',
+   'INC'	=> $INC_val,
 
    # C compiler
    #'CC' => 'gcc -std=gnu99',
@@ -68,7 +176,7 @@
    # 'CPPFLAGS' => "$Config{'cppflags'} -I/usr/include/freetype2 -I/usr/include/libxml2",
 
    # C compiler flags (e.g. -O -g)
-   'CCFLAGS' => "$Config{'ccflags'} -fopenmp -g -O2 -Wall -W -pthread",
+   'CCFLAGS' => $CCFLAGS_val,
 
    # Linker
    #'LD' => $Config{'ld'} == $Config{'cc'} ? 'gcc -std=gnu99' : $Config{'ld'},
@@ -83,7 +191,7 @@
    'INSTALLBIN'	=> '/usr/local/bin',
 
    # Library specification
-   'LIBS' => [ '-L../magick/.libs -lMagickCore -L../wand/.libs -lperl -lm' ],
+   'LIBS' => [ $LIBS_val ],
 
    # Perl binary name (if a Perl binary is built)
    'MAP_TARGET'	=> 'PerlMagick',
With current SVN trunk version there are still some warnings during compilation:

Code: Select all

cp Magick.pm blib\lib\Image\Magick.pm
AutoSplitting blib\lib\Image\Magick.pm (blib\lib\auto\Image\Magick)
D:\strawberry\perl\bin\perl.exe D:\strawberry\perl\lib\ExtUtils\xsubpp  -typemap D:\strawberry\perl\lib\ExtUtils\typemap  Magick.xs > Magick.xsc && D:\strawberry\perl\bin\perl.exe -MExtUtils::Command -e "mv" -- Magick.xsc Magick.c
gcc -c  -I"D:\tmp\ImageMagick-6.5.6-Q16\include" 	-O2 -s -O2 	  -DVERSION=\"6.5.6\" 	-DXS_VERSION=\"6.5.6\"  "-ID:\strawberry\perl\lib\CORE"  -D_LARGE_FILES=1 -DHAVE_CONFIG_H Magick.c
In file included from D:/tmp/ImageMagick-6.5.6-Q16/include/magick/color.h:26,
                 from D:/tmp/ImageMagick-6.5.6-Q16/include/magick/image.h:25,
                 from D:/tmp/ImageMagick-6.5.6-Q16/include/magick/draw.h:26,
                 from D:/tmp/ImageMagick-6.5.6-Q16/include/magick/annotate.h:25,
                 from D:/tmp/ImageMagick-6.5.6-Q16/include/magick/MagickCore.h:150,
                 from Magick.xs:64:
D:/tmp/ImageMagick-6.5.6-Q16/include/magick/exception.h:154: warning: `win32_printf' is an unrecognized format function type
D:/tmp/ImageMagick-6.5.6-Q16/include/magick/exception.h:157: warning: `win32_printf' is an unrecognized format function type
In file included from D:/tmp/ImageMagick-6.5.6-Q16/include/magick/profile.h:25,
                 from D:/tmp/ImageMagick-6.5.6-Q16/include/magick/image.h:139,
                 from D:/tmp/ImageMagick-6.5.6-Q16/include/magick/draw.h:26,
                 from D:/tmp/ImageMagick-6.5.6-Q16/include/magick/annotate.h:25,
                 from D:/tmp/ImageMagick-6.5.6-Q16/include/magick/MagickCore.h:150,
                 from Magick.xs:64:
D:/tmp/ImageMagick-6.5.6-Q16/include/magick/string_.h:68: warning: `win32_printf' is an unrecognized format function type
D:/tmp/ImageMagick-6.5.6-Q16/include/magick/string_.h:70: warning: `win32_printf' is an unrecognized format function type
In file included from D:/tmp/ImageMagick-6.5.6-Q16/include/magick/MagickCore.h:168,
                 from Magick.xs:64:
D:/tmp/ImageMagick-6.5.6-Q16/include/magick/deprecate.h:179: warning: `win32_printf' is an unrecognized format function type
D:/tmp/ImageMagick-6.5.6-Q16/include/magick/deprecate.h:181: warning: `win32_printf' is an unrecognized format function type
D:/tmp/ImageMagick-6.5.6-Q16/include/magick/deprecate.h:309: warning: `win32_printf' is an unrecognized format function type
D:/tmp/ImageMagick-6.5.6-Q16/include/magick/deprecate.h:311: warning: `win32_printf' is an unrecognized format function type
In file included from D:/tmp/ImageMagick-6.5.6-Q16/include/magick/MagickCore.h:186,
                 from Magick.xs:64:
D:/tmp/ImageMagick-6.5.6-Q16/include/magick/log.h:79: warning: `win32_printf' is an unrecognized format function type
D:/tmp/ImageMagick-6.5.6-Q16/include/magick/log.h:82: warning: `win32_printf' is an unrecognized format function type
In file included from D:/tmp/ImageMagick-6.5.6-Q16/include/magick/MagickCore.h:201,
                 from Magick.xs:64:
D:/tmp/ImageMagick-6.5.6-Q16/include/magick/property.h:39: warning: `win32_printf' is an unrecognized format function type
D:/tmp/ImageMagick-6.5.6-Q16/include/magick/property.h:41: warning: `win32_printf' is an unrecognized format function type
Magick.xs: In function `SetAttribute':
Magick.xs:1524: warning: `OpenCacheView' is deprecated (declared at D:/tmp/ImageMagick-6.5.6-Q16/include/magick/deprecate.h:291)
Magick.xs:1525: warning: `GetCacheViewPixels' is deprecated (declared at D:/tmp/ImageMagick-6.5.6-Q16/include/magick/deprecate.h:244)
Magick.xs:1528: warning: `GetCacheViewIndexes' is deprecated (declared at D:/tmp/ImageMagick-6.5.6-Q16/include/magick/deprecate.h:141)
Magick.xs:1534: warning: `CloseCacheView' is deprecated (declared at D:/tmp/ImageMagick-6.5.6-Q16/include/magick/deprecate.h:290)
Magick.xs:1754: warning: `OpenCacheView' is deprecated (declared at D:/tmp/ImageMagick-6.5.6-Q16/include/magick/deprecate.h:291)
Magick.xs:1755: warning: `GetCacheViewPixels' is deprecated (declared at D:/tmp/ImageMagick-6.5.6-Q16/include/magick/deprecate.h:244)
Magick.xs:1756: warning: `GetCacheViewIndexes' is deprecated (declared at D:/tmp/ImageMagick-6.5.6-Q16/include/magick/deprecate.h:141)
Magick.xs:1786: warning: `CloseCacheView' is deprecated (declared at D:/tmp/ImageMagick-6.5.6-Q16/include/magick/deprecate.h:290)
Magick.xs: In function `XS_Image__Magick_Get':
Magick.xs:4370: warning: `SetMagickRegistry' is deprecated (declared at D:/tmp/ImageMagick-6.5.6-Q16/include/magick/deprecate.h:155)
Magick.xs:4403: warning: `OpenCacheView' is deprecated (declared at D:/tmp/ImageMagick-6.5.6-Q16/include/magick/deprecate.h:291)
Magick.xs:4404: warning: `AcquireCacheViewPixels' is deprecated (declared at D:/tmp/ImageMagick-6.5.6-Q16/include/magick/deprecate.h:119)
Magick.xs:4407: warning: `AcquireCacheViewIndexes' is deprecated (declared at D:/tmp/ImageMagick-6.5.6-Q16/include/magick/deprecate.h:112)
Magick.xs:4413: warning: `CloseCacheView' is deprecated (declared at D:/tmp/ImageMagick-6.5.6-Q16/include/magick/deprecate.h:290)
Magick.xs:4663: warning: `AcquireIndexes' is deprecated (declared at D:/tmp/ImageMagick-6.5.6-Q16/include/magick/deprecate.h:113)
Magick.xs: In function `XS_Image__Magick_GetPixel':
Magick.xs:5770: warning: `AcquireIndexes' is deprecated (declared at D:/tmp/ImageMagick-6.5.6-Q16/include/magick/deprecate.h:113)
Magick.xs: In function `XS_Image__Magick_Mogrify':
Magick.xs:7765: warning: `OpenCacheView' is deprecated (declared at D:/tmp/ImageMagick-6.5.6-Q16/include/magick/deprecate.h:291)
Magick.xs:7768: warning: `GetCacheViewPixels' is deprecated (declared at D:/tmp/ImageMagick-6.5.6-Q16/include/magick/deprecate.h:244)
Magick.xs:7780: warning: `CloseCacheView' is deprecated (declared at D:/tmp/ImageMagick-6.5.6-Q16/include/magick/deprecate.h:290)
Running Mkbootstrap for Image::Magick ()
With current SVN trunk version there is one failing test on Win32/strawberry in t/x11/write.t (all other tests pass):

Code: Select all

D:\build\ImageMagick\PerlMagick>prove -blv t\x11\write.t
t\x11\write.t ..
1..2
not ok 1
X Windows system window dump file (color) ...
ok 2
Failed 1/2 subtests

Test Summary Report
-------------------
t\x11\write.t (Wstat: 0 Tests: 2 Failed: 1)
  Failed test:  1
Files=1, Tests=2, 12 wallclock secs ( 0.03 usr +  0.01 sys =  0.05 CPU)
Result: FAIL
--
kmx

User avatar
magick
Site Admin
Posts: 11254
Joined: 2003-05-31T11:32:55-07:00

Re: Win32 binaries & strawberry perl

Post by magick »

We added your patch to the Subversion trunk. It will be available by sometime tomorrow. Thanks.

kmx

Re: Win32 binaries & strawberry perl

Post by kmx »

Hi,

thanks for accepting my patch.

Would it be possible to put the new Win32/strawberry-ready version on CPAN in near future?

I can prepare a patch for README.TXT describing the Win32/strawberry installation if you find it useful.

--
kmx

User avatar
magick
Site Admin
Posts: 11254
Joined: 2003-05-31T11:32:55-07:00

Re: Win32 binaries & strawberry perl

Post by magick »

We'll try our best to get CPAN updated in the next week or two. Thanks.

kmx

Re: Win32 binaries & strawberry perl

Post by kmx »

Hi,

I am very sorry for making another Win32-troubles.

Please consider the enclosed patch that solves some minor issues with Perl::Magick on Win32 strawberry perl. With this patch Image::Magick installs smoothly without any compiler warning and without any failing test.

The patch is against SVN revision 413.

Thanks for being patient with my imperfect patches :).

--
kmx

Code: Select all

Index: t/x11/write.t
===================================================================
--- t/x11/write.t	(revision 413)
+++ t/x11/write.t	(working copy)
@@ -17,7 +17,7 @@
 
 # 1) Test reading and displaying an image
 #
-if ( defined($ENV{'DISPLAY'}) ) {
+if ( defined($ENV{'DISPLAY'}) && ($^O ne 'MSWin32') ) {
   $image=Image::Magick->new;
   $x=$image->ReadImage('congrats.miff');
   if( "$x" ) {
Index: Makefile.PL
===================================================================
--- Makefile.PL	(revision 413)
+++ Makefile.PL	(working copy)
@@ -117,9 +117,8 @@
    
   my $inc = join ' ', map "-I\"$_\"", @incdir;
   my $lib = join ' ', map "-L\"$_\"", @libdir;
-  $lib .= " -lMagickCore";
 
-  return ($inc, $lib, '-O2');
+  return ($inc, $lib);
 }
 
 
@@ -142,10 +141,17 @@
 my $INC_magick = '-I../ -I.. -I/usr/include/freetype2 -I/usr/include/libxml2 -I"' . $Config{'usrinc'} . '/ImageMagick"';
 my $LIBS_magick = '-L../magick/.libs -lMagickCore -lperl -lm';
 my $CCFLAGS_magick = "$Config{'ccflags'} -fopenmp -g -O2 -Wall -W -pthread";
+my $LDFLAGS_magick   = "-L../magick/.libs -lMagickCore $Config{'ldflags'} ";
+my $LDDLFLAGS_magick = "-L../magick/.libs -lMagickCore $Config{'lddlflags'} ";
 
 if (($^O eq 'MSWin32') && ($Config{cc} =~ /gcc/)) {
   # a special setup for strawberry perl
-  ($INC_magick, $LIBS_magick, $CCFLAGS_magick) = AutodetectWin32gcc();
+  my ($Ipaths, $Lpaths) = AutodetectWin32gcc();
+  $INC_magick       = "$Ipaths";
+  $LIBS_magick      = "-lMagickCore";
+  $CCFLAGS_magick   = "$Config{'ccflags'}";
+  $LDFLAGS_magick   = "$Config{'ldflags'} $Lpaths "; 
+  $LDDLFLAGS_magick = "$Config{'lddlflags'} $Lpaths ";
 }
 
 # See lib/ExtUtils/MakeMaker.pm for details of how to influence
@@ -183,10 +189,10 @@
    #'LD' => $Config{'ld'} == $Config{'cc'} ? 'gcc -std=gnu99' : $Config{'ld'},
 
    # Linker flags for building an executable
-   'LDFLAGS' =>  "-L../magick/.libs -lMagickCore $Config{'ldflags'} ",
+   'LDFLAGS' =>  $LDFLAGS_magick,
 
    # Linker flags for building a dynamically loadable module
-   'LDDLFLAGS' => "-L../magick/.libs -lMagickCore $Config{'lddlflags'} ",
+   'LDDLFLAGS' => $LDDLFLAGS_magick,
 
    # Install PerlMagick binary into ImageMagick bin directory
    'INSTALLBIN'	=> '/usr/local/bin',
Index: README.txt
===================================================================
--- README.txt	(revision 413)
+++ README.txt	(working copy)
@@ -64,7 +64,7 @@
     See the ExtUtils::MakeMaker(3) manual page for more information on
     building PERL extensions (like PerlMagick).
 
-    For Windows systems, type
+    For Windows systems (ActiveState perl + MS compiler), type
 
         perl Makefile.nt
         nmake install
@@ -74,7 +74,29 @@
     information. You are now ready to utilize the PerlMagick routines from
     within your Perl scripts.
 
+Installation - Win32 Strawberry perl
 
+   On Win32 Strawberry perl the prefered 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
+
 Testing PerlMagick
 
     Before PerlMagick is installed, you may want to execute 

User avatar
magick
Site Admin
Posts: 11254
Joined: 2003-05-31T11:32:55-07:00

Re: Win32 binaries & strawberry perl

Post by magick »

We applied your patch against the Subversion trunk. Thanks.

kmx

Re: Win32 binaries & strawberry perl

Post by kmx »

Sorry for reopeninng this discussion again. But testing with version 6.58 revealed that the following two changes are necessary for Win32/strawberry perl installation.

1) My fault: the autodetection routine was based on a lookup for DLL entry "InitializeMagickResources" which seems to be removed in 6.58. The proposed patch switches this to "InitializeMagick" entry but if you can give me a better way of detecting the right DLL I would be happy to change it again.

Code: Select all

diff -r -u PerlMagick-6.58.orig/Makefile.PL PerlMagick-6.58/Makefile.PL
--- PerlMagick-6.58.orig/Makefile.PL	2009-11-27 01:12:50.000000000 +0100
+++ PerlMagick-6.58/Makefile.PL	2009-12-07 18:49:16.364699900 +0100
@@ -76,7 +76,7 @@
       unlink "$wrkdir/libMagickCore.def", "$wrkdir/libMagickCore.a";
       system("pexports \"$d\" >\"$wrkdir/libMagickCore.def\" 2>$devnull");
       open(DEF, "<$wrkdir/libMagickCore.def");
-      my @found = grep(/InitializeMagickResources/, <DEF>); #checking if we have taken the right DLL
+      my @found = grep(/InitializeMagick/, <DEF>); #checking if we have taken the right DLL
       close(DEF);
       next unless(@found);
       print STDERR "Gonna create 'libMagickCore.a' from '$d'\n";
2) Not my fault: the proposed patch to test suite mentioned in some of my posts above was not commited into SVN:

Code: Select all

diff -r -u PerlMagick-6.58.orig/t/x11/write.t PerlMagick-6.58/t/x11/write.t
--- PerlMagick-6.58.orig/t/x11/write.t	2009-03-24 03:39:06.000000000 +0100
+++ PerlMagick-6.58/t/x11/write.t	2009-12-07 18:52:33.091288100 +0100
@@ -17,7 +17,7 @@
 
 # 1) Test reading and displaying an image
 #
-if ( defined($ENV{'DISPLAY'}) ) {
+if ( defined($ENV{'DISPLAY'}) && ($^O ne 'MSWin32') ) {
   $image=Image::Magick->new;
   $x=$image->ReadImage('congrats.miff');
   if( "$x" ) {
Hopefully we manage the version 6.59 to work well.

Thanks.

--
kmx

User avatar
magick
Site Admin
Posts: 11254
Joined: 2003-05-31T11:32:55-07:00

Re: Win32 binaries & strawberry perl

Post by magick »

We added your patch to the Subversion trunk. It will be available by sometime tomorrow. Thanks.

Locked