我正在使用 Strawbery Perl 并尝试在 Windows 11 操作系统上应用 image::Magick 包,但不断出现错误:
C:\Program Files (x86)\Microsoft Visual Studio�2\BuildTools>cpanm --force Image::Magick --> 处理 Image::Magick 获取 http://www.cpan.org/authors/id/J/JC/JCRISTY/Image-Magick-7.1.1-28.tar.gz ... OK 配置 Image-Magick-v7.1.1 ... OK 构建和测试 Image-Magick-v7.1.1 ...失败!安装 Image::Magick 失败。看 C:\Users\miki.cpanm\workz5780811.5804 uild.log 了解详细信息。重试 使用 --force 强制安装它。
“C:\Users\miki.cpanm\workz5780811.5804 uild.log”的日志文件:
cpanm (App::cpanminus) 1.7047 on perl 5.040000 built for MSWin32-x64-multi-thread
Work directory is C:\Users\miki/.cpanm/work/1725780811.5804
You have make C:\Strawberry\c\bin\gmake.exe
You have LWP 6.77
Falling back to Archive::Tar 3.02_001
Searching Image::Magick () on cpanmetadb ...
--> Working on Image::Magick
Fetching http://www.cpan.org/authors/id/J/JC/JCRISTY/Image-Magick-7.1.1-28.tar.gz
-> OK
Unpacking Image-Magick-7.1.1-28.tar.gz
Entering Image-Magick-7.1.1
Checking configure dependencies from META.json
Checking if you have ExtUtils::MakeMaker 6.58 ... Yes (7.70)
Configuring Image-Magick-v7.1.1
Running Makefile.PL
Gonna create 'libMagickCore.a' from 'C:\Program Files\ImageMagick-7.1.1-Q16\CORE_RL_MagickCore_.dll'
Checking if your kit is complete...
Looks good
Generating a gmake-style Makefile
Writing Makefile for Image::Magick
Writing MYMETA.yml and MYMETA.json
-> OK
Checking dependencies from MYMETA.json ...
Checking if you have parent 0 ... Yes (0.241)
Checking if you have ExtUtils::MakeMaker 0 ... Yes (7.70)
Building and testing Image-Magick-v7.1.1
cp Magick.pm blib\lib\Image\Magick.pm
AutoSplitting blib\lib\Image\Magick.pm (blib\lib\auto\Image\Magick)
Running Mkbootstrap for Magick ()
"C:\Strawberry\perl\bin\perl.exe" -MExtUtils::Command -e chmod -- 644 "Magick.bs"
"C:\Strawberry\perl\bin\perl.exe" -MExtUtils::Command::MM -e cp_nonempty -- Magick.bs blib\arch\auto\Image\Magick\Magick.bs 644
"C:\Strawberry\perl\bin\perl.exe" "C:\Strawberry\perl\lib\ExtUtils/xsubpp" -typemap C:\STRAWB~1\perl\lib\ExtUtils\typemap -typemap C:\Users\miki\.cpanm\work\1725780811.5804\Image-Magick-7.1.1\typemap Magick.xs > Magick.xsc
"C:\Strawberry\perl\bin\perl.exe" -MExtUtils::Command -e mv -- Magick.xsc Magick.c
gcc -c -I"C:\Program Files\ImageMagick-7.1.1-Q16\include" -std=c99 -DWIN32 -DWIN64 -DPERL_TEXTMODE_SCRIPTS -DMULTIPLICITY -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing -mms-bitfields -Os -falign-functions -falign-jumps -falign-labels -falign-loops -freorder-blocks -freorder-blocks-algorithm=stc -freorder-blocks-and-partition -DVERSION=\"7.1.1\" -DXS_VERSION=\"7.1.1\" "-IC:\STRAWB~1\perl\lib\CORE" -D_LARGE_FILES=1 -DHAVE_CONFIG_H Magick.c
In file included from C:\Program Files\ImageMagick-7.1.1-Q16\include/MagickCore/magick-config.h:25,
from C:\Program Files\ImageMagick-7.1.1-Q16\include/MagickCore/MagickCore.h:29,
from Magick.xs:56:
C:\Program Files\ImageMagick-7.1.1-Q16\include/MagickCore/magick-baseconfig.h:274:6: error: #error ImageMagick was build with a 64 channel bit mask and that requires a C++ compiler
274 | # error ImageMagick was build with a 64 channel bit mask and that requires a C++ compiler
| ^~~~~
gmake: *** [makefile:350: Magick.o] Error 1
-> FAIL Installing Image::Magick failed. See C:\Users\miki\.cpanm\work\1725780811.5804\build.log for details. Retry with --force to force install it.
看来 Perl 和 image Magick 版本都是 64 位的:
C:\Program Files (x86)\Microsoft Visual Studio�2\BuildTools>perl -v 这是 perl 5,版本 40,subversion 0 (v5.40.0) 构建的 MSWin32-x64-多线程*
C:\Program Files (x86)\Microsoft Visual Studio�2\BuildTools>perl -v 这是 perl 5,版本 40,subversion 0 (v5.40.0) 构建的 MSWin32-x64-多线程
我尝试安装多个版本的 ImageMagick(例如 ImageMagick-7.1.1-Q16)
并检查了所有选项:
已将
C:\Program Files\ImageMagick-7.1.1-Q16
添加到路径。
我还安装了 Visual studio Build tools 2022 并重新尝试通过开发人员命令提示符(也以管理员身份)从 cpan 安装。
运行
cl
似乎工作正常:
C:\Program Files (x86)\Microsoft Visual Studio�2\BuildTools>cl 适用于 x86 的 Microsoft (R) C/C++ 优化编译器版本 19.41.34120 版权所有 (C) 微软公司。 版权所有。用法: cl [ 选项...] 文件名... [ /link 链接选项... ]
运行
magick --version
似乎工作正常:
C:\Program Files (x86)\Microsoft Visual Studio�2\BuildTools>magick --version 版本:ImageMagick 7.1.1-38 Q16 x64 b0ab922:20240901 https://imagemagick.org 版权所有:(C) 1999 ImageMagick Studio LLC 许可证:https://imagemagick.org/script/license.php特点: 通道掩码(64 位) 密码 DPC 模块 OpenCL OpenMP(2.0) 代表 (内置):bzlib cairo flif freetype gslib heic jng jp2 jpeg jxl lcms lqr lzma openexr pangocairo png ps raqm raw rsvg tiff webp xml zip zlib 编译器:Visual Studio 2022 (194134120)
知道我还可以在这里尝试什么吗?
谢谢! 三木
我假设虽然从 64 位开发者命令提示符(C++ 编译器)运行 cpan 安装,但它使用其他一些默认的 32 位 C++ 编译器。 我重新安装了 32 位的 Strawberry 和 ImageMagick,问题就解决了。
谢谢!