无法安装 cpan 模块 Image::Magick

无法安装 cpan 模块 Image::Magick

这个问题仍然没有解决方案(向下滚动到“EDIT 5”查看实际状态)

我正在尝试在我的无头 Ubuntu 服务器上安装 Image::MagickUbuntu 14.04.2 LTS

# cpan install Image::Magick
Reading '/root/.cpan/Metadata'
  Database was generated on Thu, 21 May 2015 22:17:02 GMT
Running install for module 'Image::Magick'
Checksum for /root/.cpan/sources/authors/id/J/JC/JCRISTY/PerlMagick-6.89-1.tar.gz ok
Configuring J/JC/JCRISTY/PerlMagick-6.89-1.tar.gz with Makefile.PL
Checking if your kit is complete...
Looks good
Warning (mostly harmless): No library found for -lMagickCore-6.Q16
Generating a Unix-style Makefile
Writing Makefile for Image::Magick
Writing MYMETA.yml and MYMETA.json
  JCRISTY/PerlMagick-6.89-1.tar.gz
  /usr/bin/perl Makefile.PL INSTALLDIRS=site -- OK
Running make for J/JC/JCRISTY/PerlMagick-6.89-1.tar.gz
cp Magick.pm blib/lib/Image/Magick.pm
AutoSplitting blib/lib/Image/Magick.pm (blib/lib/auto/Image/Magick)
Running Mkbootstrap for Image::Magick ()
chmod 644 "Magick.bs"
"/usr/bin/perl" "/usr/local/share/perl/5.18.2/ExtUtils/xsubpp"  -typemap "/usr/share/perl/5.18/ExtUtils/typemap" -typemap "typemap"  Magick.xs > Magick.xsc && mv Magick.xsc Magick.c
cc -c  -I/usr/local/include/ImageMagick-6 -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/libxml2 -I"/usr/include/ImageMagick-6" -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fstack-protector -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/freetype2 -g -O2 -Wall -pthread -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -O2 -g   -DVERSION=\"6.89\" -DXS_VERSION=\"6.89\" -fPIC "-I/usr/lib/perl/5.18/CORE"  -D_LARGE_FILES=1 -DHAVE_CONFIG_H Magick.c
Magick.xs:60:31: fatal error: magick/MagickCore.h: Datei oder Verzeichnis nicht gefunden
 #include <magick/MagickCore.h>
                               ^
compilation terminated.
make: *** [Magick.o] Fehler 1
  JCRISTY/PerlMagick-6.89-1.tar.gz
  make -- NOT OK

显然,安装脚本试图包含头文件 magick/MagickCore.h,但找不到它。

当我在搜索引擎中搜索 magick/MagickCore.h 时,我发现很多帖子,其中有些人遇到了同样的问题并询问,但我没有找到解决方案,只找到很多答案说“我有同样的问题”——没有解决方案。

你们中有人有适用于 Ubuntu Server 14.04.2 的解决方案吗?

编辑1:
我已经安装了 ImageMagic 包:

# apt-get install imagemagick

但我仍然收到上面发布的错误。

编辑2:
按照其中一个答案的建议,我也尝试过

# apt-get install php5-imagick

其次是

# cpan install Image::Magick  

但我仍然收到相同的错误(脚本找不到 magick/MagickCore.h)

编辑3:
我听从了另一个建议并搜索了magick/MagickCore.h。答案是:

libmagickcore-dev: /usr/include/ImageMagick/magick/MagickCore.h

所以我安装了libmagickcore-dev(我sudo -i之前曾预期过):

apt-get install libmagickcore-dev

此安装成功,之前缺少的头文件现在位于文件系统中:

# find / -name MagickCore.h
/usr/include/ImageMagick/magick/MagickCore.h

所以我再次尝试

cpan install Image::Magick

但我仍然收到此错误:

Magick.xs:60:31: fatal error: magick/MagickCore.h: Datei oder Verzeichnis nicht gefunden
 #include <magick/MagickCore.h>
                               ^
compilation terminated.

(»未找到数据或记录« 是德语,我的母语,意思是 »没有这样的文件或目录«)

编辑4:
有人告诉我,编译器正在寻找的magick/MagickCore.h不是/usr/include/ImageMagick/而是/usr/include/ImageMagick-6/。所以我创建了一个符号链接:

sudo ln -s /usr/include/ImageMagick /usr/include/ImageMagick-6

并再次尝试安装模块:

# cpan install Image::Magick
...
chmod 644 "Magick.bs"
"/usr/bin/perl" "/usr/local/share/perl/5.18.2/ExtUtils/xsubpp"  -typemap "/usr/share/perl/5.18/ExtUtils/typemap" -typemap "typemap"  Magick.xs > Magick.xsc && mv Magick.xsc Magick.c
cc -c  -I/usr/local/include/ImageMagick-6 -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/libxml2 -I"/usr/include/ImageMagick-6" -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fstack-protector -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/freetype2 -g -O2 -Wall -pthread -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -O2 -g   -DVERSION=\"6.89\" -DXS_VERSION=\"6.89\" -fPIC "-I/usr/lib/perl/5.18/CORE"  -D_LARGE_FILES=1 -DHAVE_CONFIG_H Magick.c
Magick.xs:545:33: error: ‘MagickPixelIntensityOptions’ undeclared here (not in a function)
     { "Grayscale", { {"method", MagickPixelIntensityOptions} } },
                                 ^
Magick.xs: In function ‘XS_Image__Magick_ComplexImages’:
Magick.xs:3475:5: error: unknown type name ‘ComplexOperator’
     ComplexOperator
     ^
Magick.xs:3510:8: error: ‘UndefinedComplexOperator’ undeclared (first use in this function)
     op=UndefinedComplexOperator;
        ^
...
Magick.xs:10939:16: warning: assignment makes pointer from integer without a cast [enabled by default]
           image=MeanShiftImage(image,(size_t) geometry_info.rho,(size_t)
                ^
make: *** [Magick.o] Fehler 1
  JCRISTY/PerlMagick-6.89-1.tar.gz
  make -- NOT OK

因此,脚本确实找到了magick/MagickCore.h,但现在引发了许多其他错误。


编辑 5 (2015-09-17)

我收到安装提示

apt-get 安装 perlmagick

但它说已经安装了最新版本。但我还是尝试安装 Image::Magick。它仍然不起作用:

# cpan install Image::Magick
Reading '/root/.cpan/Metadata'
  Database was generated on Mon, 31 Aug 2015 22:41:03 GMT
Fetching with LWP:
http://ftp.u-tx.net/CPAN/authors/01mailrc.txt.gz
Reading '/root/.cpan/sources/authors/01mailrc.txt.gz'
............................................................................DONE
Fetching with LWP:
http://ftp.u-tx.net/CPAN/modules/02packages.details.txt.gz
Reading '/root/.cpan/sources/modules/02packages.details.txt.gz'
  Database was generated on Wed, 16 Sep 2015 22:41:02 GMT
............................................................................DONE
Fetching with LWP:
http://ftp.u-tx.net/CPAN/modules/03modlist.data.gz
Reading '/root/.cpan/sources/modules/03modlist.data.gz'
DONE
Writing /root/.cpan/Metadata
Running install for module 'Image::Magick'
Checksum for /root/.cpan/sources/authors/id/J/JC/JCRISTY/PerlMagick-6.89-1.tar.gz ok
tmp-18091 for tmp-18091: Datei oder Verzeichnis nicht gefunden at /usr/share/perl/5.18/CPAN/Distribution.pm line 468.
Configuring J/JC/JCRISTY/PerlMagick-6.89-1.tar.gz with Makefile.PL
Checking if your kit is complete...
Looks good
Warning (mostly harmless): No library found for -lMagickCore-6.Q16
Generating a Unix-style Makefile
Writing Makefile for Image::Magick
Writing MYMETA.yml and MYMETA.json
  JCRISTY/PerlMagick-6.89-1.tar.gz
  /usr/bin/perl Makefile.PL INSTALLDIRS=site -- OK
Running make for J/JC/JCRISTY/PerlMagick-6.89-1.tar.gz
cp Magick.pm blib/lib/Image/Magick.pm
AutoSplitting blib/lib/Image/Magick.pm (blib/lib/auto/Image/Magick)
Running Mkbootstrap for Image::Magick ()
chmod 644 "Magick.bs"
"/usr/bin/perl" "/usr/local/share/perl/5.18.2/ExtUtils/xsubpp"  -typemap "/usr/share/perl/5.18/ExtUtils/typemap" -typemap "typemap"  Magick.xs > Magick.xsc && mv Magick.xsc Magick.c
cc -c  -I/usr/local/include/ImageMagick-6 -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/include/libxml2 -I"/usr/include/ImageMagick-6" -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fstack-protector -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/freetype2 -g -O2 -Wall -pthread -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16 -O2 -g   -DVERSION=\"6.89\" -DXS_VERSION=\"6.89\" -fPIC "-I/usr/lib/perl/5.18/CORE"  -D_LARGE_FILES=1 -DHAVE_CONFIG_H Magick.c
Magick.xs:545:33: error: ‘MagickPixelIntensityOptions’ undeclared here (not in a function)
     { "Grayscale", { {"method", MagickPixelIntensityOptions} } },
                                 ^
Magick.xs: In function ‘XS_Image__Magick_ComplexImages’:
Magick.xs:3475:5: error: unknown type name ‘ComplexOperator’
     ComplexOperator
     ^
Magick.xs:3510:8: error: ‘UndefinedComplexOperator’ undeclared (first use in this function)
     op=UndefinedComplexOperator;
        ^
Magick.xs:3510:8: note: each undeclared identifier is reported only once for each function it appears in
Magick.xs:3510:7: warning: assignment makes integer from pointer without a cast [enabled by default]
     op=UndefinedComplexOperator;
       ^
Magick.xs:3516:31: error: ‘MagickComplexOptions’ undeclared (first use in this function)
         in=ParseCommandOption(MagickComplexOptions,MagickFalse,(char *)
                               ^
Magick.xs:3517:11: error: incompatible type for argument 1 of ‘ParseCommandOption’
           SvPV(ST(1),na));
           ^
In file included from /usr/include/ImageMagick-6/magick/MagickCore.h:115:0,
                 from Magick.xs:60:
/usr/include/ImageMagick-6/magick/option.h:166:3: note: expected ‘CommandOption’ but argument is of type ‘struct Methods *’
   ParseCommandOption(const CommandOption,const MagickBooleanType,const char *);
   ^
Magick.xs:3516:11: warning: assignment makes integer from pointer without a cast [enabled by default]
         in=ParseCommandOption(MagickComplexOptions,MagickFalse,(char *)
           ^
Magick.xs:3524:13: error: ‘ComplexOperator’ undeclared (first use in this function)
         op=(ComplexOperator) in;
             ^
Magick.xs:3524:11: warning: assignment makes integer from pointer without a cast [enabled by default]
         op=(ComplexOperator) in;
           ^
Magick.xs:3524:30: error: expected ‘;’ before ‘in’
         op=(ComplexOperator) in;
                              ^
Magick.xs:3541:19: error: incompatible type for argument 1 of ‘ParseCommandOption’
                   MagickComplexOptions,MagickFalse,SvPV(ST(i),na));
                   ^
In file included from /usr/include/ImageMagick-6/magick/MagickCore.h:115:0,
                 from Magick.xs:60:
/usr/include/ImageMagick-6/magick/option.h:166:3: note: expected ‘CommandOption’ but argument is of type ‘struct Methods *’
   ParseCommandOption(const CommandOption,const MagickBooleanType,const char *);
   ^
Magick.xs:3540:48: warning: pointer/integer type mismatch in conditional expression [enabled by default]
                 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
                                                ^
Magick.xs:3540:19: warning: assignment makes integer from pointer without a cast [enabled by default]
                 in=!SvPOK(ST(i)) ? SvIV(ST(i)) : ParseCommandOption(
                   ^
Magick.xs:3548:19: warning: assignment makes integer from pointer without a cast [enabled by default]
                 op=(ComplexOperator) in;
                   ^
Magick.xs:3548:38: error: expected ‘;’ before ‘in’
                 op=(ComplexOperator) in;
                                      ^
Magick.xs:3563:5: warning: implicit declaration of function ‘ComplexImages’ [-Wimplicit-function-declaration]
     image=ComplexImages(image,op,exception);
     ^
Magick.xs:3563:10: warning: assignment makes pointer from integer without a cast [enabled by default]
     image=ComplexImages(image,op,exception);
          ^
Magick.xs: In function ‘XS_Image__Magick_Mogrify’:
Magick.xs:9175:11: warning: implicit declaration of function ‘SolarizeImageChannel’ [-Wimplicit-function-declaration]
           (void) SolarizeImageChannel(image,channel,geometry_info.rho,
           ^
Magick.xs:9824:11: warning: implicit declaration of function ‘RotationalBlurImageChannel’ [-Wimplicit-function-declaration]
           image=RotationalBlurImageChannel(image,channel,geometry_info.rho,
           ^
Magick.xs:9824:16: warning: assignment makes pointer from integer without a cast [enabled by default]
           image=RotationalBlurImageChannel(image,channel,geometry_info.rho,
                ^
Magick.xs:10112:11: warning: implicit declaration of function ‘AutoOrientImage’ [-Wimplicit-function-declaration]
           image=AutoOrientImage(image,image->orientation,exception);
           ^
Magick.xs:10112:16: warning: assignment makes pointer from integer without a cast [enabled by default]
           image=AutoOrientImage(image,image->orientation,exception);
                ^
Magick.xs:10824:11: warning: implicit declaration of function ‘PerceptibleImageChannel’ [-Wimplicit-function-declaration]
           (void) PerceptibleImageChannel(image,channel,epsilon);
           ^
Magick.xs:10853:11: warning: implicit declaration of function ‘PolynomialImageChannel’ [-Wimplicit-function-declaration]
           image=PolynomialImageChannel(image,channel,number_terms >> 1,terms,
           ^
Magick.xs:10853:16: warning: assignment makes pointer from integer without a cast [enabled by default]
           image=PolynomialImageChannel(image,channel,number_terms >> 1,terms,
                ^
Magick.xs:10860:11: error: unknown type name ‘PixelIntensityMethod’
           PixelIntensityMethod
           ^
Magick.xs:10863:18: error: ‘UndefinedPixelIntensityMethod’ undeclared (first use in this function)
           method=UndefinedPixelIntensityMethod;
                  ^
Magick.xs:10863:17: warning: assignment makes integer from pointer without a cast [enabled by default]
           method=UndefinedPixelIntensityMethod;
                 ^
Magick.xs:10865:21: error: ‘PixelIntensityMethod’ undeclared (first use in this function)
             method=(PixelIntensityMethod) argument_list[0].integer_reference;
                     ^
Magick.xs:10865:19: warning: assignment makes integer from pointer without a cast [enabled by default]
             method=(PixelIntensityMethod) argument_list[0].integer_reference;
                   ^
Magick.xs:10865:43: error: expected ‘;’ before ‘argument_list’
             method=(PixelIntensityMethod) argument_list[0].integer_reference;
                                           ^
Magick.xs:10866:11: warning: implicit declaration of function ‘GrayscaleImage’ [-Wimplicit-function-declaration]
           (void) GrayscaleImage(image,method);
           ^
Magick.xs:10895:11: warning: implicit declaration of function ‘CannyEdgeImage’ [-Wimplicit-function-declaration]
           image=CannyEdgeImage(image,geometry_info.rho,geometry_info.sigma,
           ^
Magick.xs:10895:16: warning: assignment makes pointer from integer without a cast [enabled by default]
           image=CannyEdgeImage(image,geometry_info.rho,geometry_info.sigma,
                ^
Magick.xs:10916:11: warning: implicit declaration of function ‘HoughLineImage’ [-Wimplicit-function-declaration]
           image=HoughLineImage(image,(size_t) geometry_info.rho,(size_t)
           ^
Magick.xs:10916:16: warning: assignment makes pointer from integer without a cast [enabled by default]
           image=HoughLineImage(image,(size_t) geometry_info.rho,(size_t)
                ^
Magick.xs:10939:11: warning: implicit declaration of function ‘MeanShiftImage’ [-Wimplicit-function-declaration]
           image=MeanShiftImage(image,(size_t) geometry_info.rho,(size_t)
           ^
Magick.xs:10939:16: warning: assignment makes pointer from integer without a cast [enabled by default]
           image=MeanShiftImage(image,(size_t) geometry_info.rho,(size_t)
                ^
make: *** [Magick.o] Fehler 1
  JCRISTY/PerlMagick-6.89-1.tar.gz
  make -- NOT OK

这是报告的第一个错误:

tmp-18091 对于 tmp-18091:数据或版本未在 /usr/share/perl/5.18/CPAN/Distribution.pm 第 468 行找到。

可能是英文:

tmp-18091 对于 tmp-18091:在 /usr/share/perl/5.18/CPAN/Distribution.pm 第 468 行没有该文件或目录。

答案1

迭戈的解决方案有效。

对于我来说,对于 ImageMagick-6.9.1 和 ImageMagick-6.9.5 版本,类似的过程也起作用。

从源代码构建 Image::Magick perl 模块

去:http://www.imagemagick.org/script/download.php

从其中一个镜像下载 tar.gz 文件:

ftp://ftp.kddlabs.co.jp/graphics/ImageMagick/ImageMagick-6.9.5-8.tar.gz

解压到 ~/home/src 中:

$ cd ~/home/src
$ mv ~/Downloads/ImageMagick-6.9.5-8.tar.gz .
$ tar xzvf ImageMagick-6.9.5-8.tar.gz

使用 Perl 绑定配置 Image Magic

$ cd ImageMagick-6.9.5-8
$ ./configure --with-perl
$ make

确保已安装 perl dev 文件

$ sudo-apt get install libperl-dev

安装 Image Magick

$ make install  # or sudo make install

检查它是否正常工作:

$ perldoc Image::Magick

资源:

http://www.imagemagick.org/script/perl-magick.php
http://www.imagemagick.org/script/examples.php
http://www.imagemagick.org/script/command-line-options.php

答案2

我安装 Image magick 的最终解决方案是:

(尝试完所有步骤后)

从以下位置下载当前版本的 ImageMagick来源

6.9.2就我而言:

下载完成后,切换到下载文件夹并:

tar xvfz ImageMagick-6.9.2-4.tar.gz
cd ImageMagick-6.9.2-4/
./configure --with-perl
make
(*)
sudo make install

然后一切顺利

(*)另一个缺失的部分,lperl因此在此过程中我必须添加: sudo apt-get install libperl-dev

答案3

安装该包php5-imagick并再次尝试通过 CPAN 安装。

答案4

显然,perl-lib 的维护不如 Ubuntu repos 完善。

apt-get install libimage-magick-perl

修复了 cpanm 失败的问题。

相关内容