草莓Perl 5.12上的Image::Magick

3
我正试图在Windows XP上的Strawberry Perl 5.12上安装Image::Magick,但它在生成makefile时找不到ImageMagick模块。同时,make也会抛出许多编译器错误。
我完全按照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

我得到了这个:

################################### 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

但是ImageMagick二进制文件已安装并在路径变量中。
我该如何运行它?

这些缺失的库看起来非常像步骤5中提到的Visual C++可再发行程序包。Win32专家,请确认一下。 - daxim
Visual C++ 可再发行程序包已安装在我的系统上。 - Demnogonis
如果您从命令行运行“convert.exe”,它会失败吗? - Alexandr Ciornii
不,它可以工作。Image Magick在路径中。 - Demnogonis
2个回答

2
我有一个解决方案!
问题是,Makefile.pl 在错误的目录中查找二进制文件。
以下是解决步骤:
1. 获取最新的ImageMagick软件包。 点击 2. 解压并进入PerlMagick文件夹
3. 用编辑器打开Makefile.pl 4. 查看第一个foreach块:

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") };
}

该脚本从%PATH%获取IM安装位置,并查找bin、lib和include文件夹。它会在实际位置以外的所有地方寻找。

因此,您只需要添加以下内容:

# 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');
...

之后,您可以执行perl Makefile.pl命令,它会正确地生成makefile文件。然后只需输入dmakedmake install命令,就可以完成安装。

希望这能帮助到某个人。


哇,伙计!你是我的英雄!这个方法对我太有用了,我之前非常沮丧,因为没有其他可尝试的方法...但它对我起作用了,我成功安装了它。谢谢你! - Sismetic
我现在在执行dmake测试时遇到了一些问题。也许你可以帮我解决一下。这是线程链接:http://stackoverflow.com/questions/13462775/test-failure-in-dmake-test-with-module-perlmagickimagemagick。我会非常感激。 - Sismetic
@Demnogonis,您的更正现在已经集成到PerlMagick-6.89\Makefile.PL中,但是,在我的情况下,在Windows 10上,我遇到了fatal error: magick/MagickCore.h: No such file or directory的问题... - joharr

1
你也可以尝试一种不那么痛苦的方法 - 使用随附Strawberry Perl的Perl软件包管理器。
使用"ppm"命令开始,然后键入"install Image-Magick"。30秒即可完成。

草莓 Perl 自带了它自己的 ppm,并且它的表现甚至更好。 最近我从 ActivePerl 迁移,因为他们希望使用他们的 Perl 版本需要越来越多的金钱。早期,在 Windows 上使用 Perl 时除了那些用 Visual Studio 编译所有东西的狂热者外,没有其他选择,而我一直跟随着他们 :) 但现在他们太贪婪了,我找到了这个美妙的替代品。 它仅缺少 GUI 调试器,但 ActivePerl PDK 可以很好地与草莓 Perl 兼容。 - Sly
感谢澄清。原则上似乎可以工作。不幸的是,最新的Strawberry版本没有Image-Magick可用,因此有时仍需要使用CPAN.pm。 - Slaven Rezic
ppm和cpan不是做同样的事情吗?从repo下载包并执行有缺陷的makefile.pl?我从未使用过ActivePerl,因此对ppm的内部工作原理一无所知。 - Demnogonis
不需要编译器,也不需要等待,ppm安装预编译的二进制文件只需几秒钟 - 如果有预编译模块版本可用。 - Sly
这似乎适用于我的 Windows 10, version 1709,使用 ImageMagick 7.0.7-28 Q16 (64-bit) > 安装 C 和 C++ 的开发头文件和库,但后来发现不能读取 jpeg 文件... - joharr

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接