简体   繁体   中英

Install Perl Image::Magick on Fedora

I'm installing Image::Magick via cpan and I keep getting this error. I've tried with and without forcing it. I've trimmed the install log. I've read something about missing an ImageMagick.h file but don't exactly know anything other then that. Apparently this has been a common problem since 2007.....

[gandalf@Durmstrang ~]$ cpan -if Image::Magick

"/usr/bin/perl" "/usr/share/perl5/vendor_perl/ExtUtils/xsubpp"  -typemap "/usr/share/perl5/ExtUtils/typemap" -typemap "typemap"  Magick.xs > Magick.xsc && mv Magick.xsc Magick.c
gcc -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 -fno-strict-aliasing -pipe -fstack-protector -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 -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic   -DVERSION=\"6.89\" -DXS_VERSION=\"6.89\" -fPIC "-I/usr/lib64/perl5/CORE"  -D_LARGE_FILES=1 -DHAVE_CONFIG_H Magick.c
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:3516:31: error: ‘MagickComplexOptions’ undeclared (first use in this function)
         in=ParseCommandOption(MagickComplexOptions,MagickFalse,(char *)
                               ^
Magick.xs:3524:13: error: ‘ComplexOperator’ undeclared (first use in this function)
         op=(ComplexOperator) in;
             ^
Magick.xs:3524:30: error: expected ‘;’ before ‘in’
         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: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: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] Error 1
  JCRISTY/PerlMagick-6.89-1.tar.gz
  /usr/bin/make -- NOT OK
Running make test
  Can't test without successful make
Running make install
  Make had returned bad status, install seems impossible

The problem is that CPAN doesn't know about non-Perl dependencies.

The Perl Image::Magick module is just a wrapper around a C library. You'll need that library installed before you can build the Perl module.

$ sudo yum install ImageMagick

It also probably need ImageMagick's development package.

$ sudo yum install ImageMagick-devel

But it's probably easier to just install the RPM version that has already been packaged for Fedora (that will automatically pull in any other requirements).

$ sudo yum install ImageMagick-perl

In Fedora, CentOS, Ubuntu and more there have been this type of challenge in geting Image::Magick to install via the cpan program, and there have been sensitivities about the install-script for Image::Magick for a couple of years, it seems (if one searches around). This is so both for on desktop Linux and, even more so, via Apache cpanel. There are recipies but at least at Ubuntu, they have not been solving all issues. Sometimes, to get it right, one must first do removal of relevant libraries using ImageMagick to reset the links. All the proposed solutions center around installing other things before using 'cpan'. However, the best approach, I find, isn't at all to compile from source but to install the binary ImageMagick application when that is available, and relevant libraries before and after cpan, like this--in Ubuntu, but adapted for Fedora it should be similar or much the same:

sudo apt-get install perlmagick
sudo apt-get install ImageMagick
sudo cpan install Image::Magick
sudo apt-get install libperl-dev

For the sake of completeness, if one cannot find the right binary, one must take care to preinstall all relevant libraries as indicated on http://www.imagemagick.org and then this set of commands will replace the line#2 above, when performed after 'sudo -i' (in Ubuntu) or equivalent in Fedora, inside a temporary folder:

wget http://www.imagemagick.org/download/ImageMagick.tar.gz
tar xvfz ImageMagick.tar.gz
cd Imag*
./configure --with-perl
make
make install

When this installation is complete, proceed with line#3 above. Adapt the beginning of the command to the form that fits with other forms of linuxes. After this, a perl program having use Image::Magick; in its start should be able to do such as resizing of jpg images etc flawlessly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM