http://www.perlmonks.org?node_id=11157708


in reply to Re^3: Errors While Installing Image::Magick
in thread Errors While Installing Image::Magick

But I wonder if there's a compiler switch (maybe -std=c++11) that would fix that for you.

Not that I can find.
Having upgraded the ImageMagick executable from release 19 to release 28, I hit the same issue.
To fix, I did a cd to the .cpan build directory and started by removing the failed cpan -fi Image::Magick attempt:
C:\> cd \Users\Owner\.cpan\build\Image-Magick-7.1.1-18 then C:\Users\Owner\.cpan\build\Image-Magick-7.1.1-18>gmake realclean then C:\Users\Owner\.cpan\build\Image-Magick-7.1.1-18>perl Makefile.PL CC=g +++ then C:\Users\Owner\.cpan\build\Image-Magick-7.1.1-18>gmake test then C:\Users\Owner\.cpan\build\Image-Magick-7.1.1-18>gmake install
That worked fine for me, though the single test still failed:
t/blob.t .......... ok t/composite.t ..... ok t/filter.t ........ Failed 1/58 subtests t/getattribute.t .. ok t/montage.t ....... ok t/ping.t .......... ok t/read.t .......... ok t/setattribute.t .. ok t/write.t ......... ok Test Summary Report ------------------- t/filter.t (Wstat: 0 Tests: 58 Failed: 1) Failed test: 2 Files=9, Tests=273, 1 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 C +PU) Result: FAIL Failed 1/9 test programs. 1/273 subtests failed. gmake: *** [makefile:1048: test_dynamic] Error 255
Update: Looks like that one test fails for me because the font "Generic.ttf" can't be found:
Annotate(text=>'Magick',geometry=>'+0+20',font=>'Generic.ttf',fill=>'g +old',gravity=>'North',pointsize=>14) ... Annotate (text=>'Magick',geometry=>'+0+20',font=>'Generic.ttf',fill= +>'gold',gravity=>'North',pointsize=>14): Exception 305: unable to read font `Generic.ttf' @ warning/annotate. +c/RenderType/1024 not ok 2
Update 2: In the previous versions of Image::Magick that I've built, "Generic.tiff" has been provided in both the "demo" and the "t" folders - though the MANIFEST file listed only "demo/Generic.tiff"..
Now, however, "Generic.tiff" is to be found only in the "demo" folder.
Copying "demo/Generic.tiff" to "t/Generic.tiff" allows all tests to pass.

Cheers,
Rob

Replies are listed 'Best First'.
Re^5: Errors While Installing Image::Magick
by roho (Bishop) on Feb 15, 2024 at 19:11 UTC
    Thanks for the helpful suggestions syphilis. Here is a summary of the latest things I have tried, per your suggestions. I still haven't been able isolate the source of "ccflags".

    I'm closer, thanks to you, but still no cigar. :-)

    Update: I believe the basic question comes down to whether the gcc compiler in Strawberry Perl 5.24.1 is capable of compiling the code for Image::Magick, and if not, is there a viable alternative that does not involve upgrading to a more recent version of Perl? For now, I must remain at 5.24.1 for a number of reasons.


    I did the "Clean and rerun install" -- got the following errors with gmake test:
    ---------------------------------------------------------------------------------------------
    cd \Users\Owner\.cpan\build\Image-Magick-7.1.1-18
    C:\Users\Owner\.cpan\build\Image-Magick-7.1.1-18>gmake realclean
    C:\Users\Owner\.cpan\build\Image-Magick-7.1.1-18>perl Makefile.PL CC=g++
    C:\Users\Owner\.cpan\build\Image-Magick-7.1.1-18>gmake test
    C:\Users\Owner\.cpan\build\Image-Magick-7.1.1-18>gmake install

    C:\Strawberry\cpan\build\Image-Magick-7.1.1-10> gmake test {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_nonemp +ty -- Magick.bs blib\arch\auto\Image\Magick\Magick.bs 644 "C:\Strawberry\perl\bin\perl.exe" "C:\Strawberry\perl\lib\ExtUtils\\xs +ubpp" -typemap C:\strawberry\perl\lib\ExtUtils\typemap -typemap C:\S +trawberry\cpan\build\Image-Magick-7.1.1-10\typemap Magick.xs > Magic +k.xsc "C:\Strawberry\perl\bin\perl.exe" -MExtUtils::Command -e mv -- Magick. +xsc Magick.c g++ -c -I"C:\Program Files\ImageMagick-7.1.1-Q16-HDRI\include" -s -O2 + -DWIN32 -DWIN64 -DCONSERVATIVE -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLI +CIT_CONTEXT -DPERL_IMPLICIT_SYS -fwrapv -fno-strict-aliasing -mms-bit +fields -s -O2 -DVERSION=\"7.1.1\" -DXS_VERSION=\"7.1.1\" "-IC:\strawberry\perl\lib\CORE" -D_LARGE_FILES=1 -DHAVE_CONFIG_H Magi +ck.c In file included from C:\Program Files\ImageMagick-7.1.1-Q16-HDRI\incl +ude/MagickCore/stream.h:25:0, from C:\Program Files\ImageMagick-7.1.1-Q16-HDRI\incl +ude/MagickCore/blob.h:49, from C:\Program Files\ImageMagick-7.1.1-Q16-HDRI\incl +ude/MagickCore/image.h:111, from C:\Program Files\ImageMagick-7.1.1-Q16-HDRI\incl +ude/MagickCore/draw.h:22, from C:\Program Files\ImageMagick-7.1.1-Q16-HDRI\incl +ude/MagickCore/annotate.h:21, from C:\Program Files\ImageMagick-7.1.1-Q16-HDRI\incl +ude/MagickCore/MagickCore.h:80, from Magick.xs:56: C:\Program Files\ImageMagick-7.1.1-Q16-HDRI\include/MagickCore/pixel.h +:34:16: warning: scoped enums only available with -std=c++11 or -std= +gnu++11 typedef enum : MagickOffsetType ^ "C:\Strawberry\perl\bin\perl.exe" -MExtUtils::Mksymlists \ -e "Mksymlists('NAME'=>\"Image::Magick\", 'DLBASE' => 'Magick', ' +DL_FUNCS' => { }, 'FUNCLIST' => [], 'IMPORTS' => { }, 'DL_VARS' => +[]);" g++ Magick.def -o blib\arch\auto\Image\Magick\Magick.xs.dll -mdll -s - +L"C:\strawberry\perl\lib\CORE" -L"C:\strawberry\c\lib" -L"C:/Strawber +ry/cpan/build/Image-Magick-7.1.1-10" -L"C:\Program Files\ImageMagick- +7.1.1-Q16-HDRI\lib" Magick.o "C:\strawberry\perl\lib\CORE \libperl524.a" "libMagickCore.a" "C:\strawberry\c\x86_64-w64-mingw32\l +ib\libmoldname.a" "C:\strawberry\c\x86_64-w64-mingw32\lib\libkernel32 +.a" "C:\strawberry\c\x86_64-w64-mingw32\lib\libuser32.a" "C:\strawber +ry\c\x86_64-w64-mingw32\lib\libgdi32.a" "C:\strawberry\c\x86 _64-w64-mingw32\lib\libwinspool.a" "C:\strawberry\c\x86_64-w64-mingw32 +\lib\libcomdlg32.a" "C:\strawberry\c\x86_64-w64-mingw32\lib\libadvapi +32.a" "C:\strawberry\c\x86_64-w64-mingw32\lib\libshell32.a" "C:\straw +berry\c\x86_64-w64-mingw32\lib\libole32.a" "C:\strawberry\c\ x86_64-w64-mingw32\lib\liboleaut32.a" "C:\strawberry\c\x86_64-w64-ming +w32\lib\libnetapi32.a" "C:\strawberry\c\x86_64-w64-mingw32\lib\libuui +d.a" "C:\strawberry\c\x86_64-w64-mingw32\lib\libws2_32.a" "C:\strawbe +rry\c\x86_64-w64-mingw32\lib\libmpr.a" "C:\strawberry\c\x86_ 64-w64-mingw32\lib\libwinmm.a" "C:\strawberry\c\x86_64-w64-mingw32\lib +\libversion.a" "C:\strawberry\c\x86_64-w64-mingw32\lib\libodbc32.a" " +C:\strawberry\c\x86_64-w64-mingw32\lib\libodbccp32.a" "C:\strawberry\ +c\x86_64-w64-mingw32\lib\libcomctl32.a" -Wl,--enable-auto-im age-base "C:\Strawberry\perl\bin\perl.exe" -MExtUtils::Command -e chmod -- 755 +blib\arch\auto\Image\Magick\Magick.xs.dll fileparse(): need a valid pathname at C:/Strawberry/perl/site/lib/ExtU +tils/Install.pm line 1187. makefile:1067: recipe for target 'pm_to_blib' failed gmake: *** [pm_to_blib] Error 255 C:\Strawberry\cpan\build\Image-Magick-7.1.1-10> gmake install fileparse(): need a valid pathname at C:/Strawberry/perl/site/lib/ExtU +tils/Install.pm line 1187. makefile:1067: recipe for target 'pm_to_blib' failed gmake: *** [pm_to_blib] Error 255


    I tried editing the following files and found this:
    ----------------------------------------------------------
    C:\Strawberry\perl\lib\Config.pm -- No "ccflags" entries in this file.
    C:\Strawberry\perl\lib\Config_heavy.pl -- I found: cc='$cc', ccflags ='$ccflags', but $ccflags is set somewhere else (this is the only reference).


    I ran the following to display the contents of $Config{ccflags}:
    ----------------------------------------------------------------------------
    perl -MConfig -e "print $Config{ccflags}
    -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fwrapv -fno-strict-aliasing -mms-bitfields


    I fixed the missing "Generic.tiff" file:
    ---------------------------------------------
    cd C:\Strawberry\cpan\build\Image-Magick-7.1.1-10
    copy demo\Generic.ttf t\

    "It's not how hard you work, it's how much you get done."

      fileparse(): need a valid pathname at C:/Strawberry/perl/site/lib/ExtUtils/Install.pm line 1187.

      I've installed SP-5.24.1.1 - same version as yours, but I can't reproduce the problem.
      I've grabbed the "portable" version, not the "msi installer" - but that should make no difference.
      I do see the "scoped enums only available with -std=c++11 or -std=gnu++11" warning, but the build succeeds anyway.

      So I think we're looking at a problem with ExtUtils::MakeMaker.
      What version of ExtUtils::MakeMaker do you have ?
      Strawberry 5.24.1 shipped with version 7.24, and that's the version I've used.
      On Strawberry 5.24.4 (which I already had), version 7.34 is installed - and there was no problem with it, either.

      Also, what does line 1187 of Install.pm state ? (We might be able to fix your issue by patching that file.)

      Update:
      C:\Strawberry\perl\lib\Config.pm -- No "ccflags" entries in this file.
      C:\Strawberry\perl\lib\Config_heavy.pl -- I found: cc='$cc', ccflags ='$ccflags', but $ccflags is set somewhere else (this is the only reference).


      Sorry - skimmed past that.
      Yes - wrt altering of $Config{ccflags}, it's only Config_heavy.pl that needs patching.
      If you keep searching further through that file you'll come to the line that needs to be altered. Search for ccflags=
      I think you can also temporarily override ccflags the same way as I did for cc:
      perl Makefile.PL CC=g++ CCFLAGS="full space-delimited list of all the +flags that you want"
      Cheers,
      Rob
      • I have ExtUtils::MakeMaker (version 7.24).

      • The temporary override "perl Makefile.PL CC=g++" works ok.

      • I researched the error message "fileparse(): need a valid pathname" at line 1187 and found that it is issued by module "File::Basename qw(dirname)".

        This is as far as I've gotten trying to track down the source of the error in C:\Strawberry\perl\site\lib\ExtUtils\Install.pm.

        7 use File::Basename qw(dirname);
        1165 while(my($from, $to) = each %$fromto) {
        1187 my $dirname = dirname($to);

        It appears the "$to" variable in line 1187 which comes from the "%$fromto" hash in line 1165 is empty, but I feel like I'm on the verge of descending into a rabbit hole here. :-)

        Update: I took my research one step further and found that the subroutine "pm_to_blib" in C:\Strawberry\perl\site\lib\ExtUtils\Install.pm is referenced in the following makefile:
        C:\Strawberry\cpan\build\Image-Magick-7.1.1-10\Makefile

        ... and that's where my expertise in this area ends. :-(

        "It's not how hard you work, it's how much you get done."