PerlMagick make has 6 errors: syntax, permissions, bad exec format

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
BrianP007
Posts: 49
Joined: 2013-12-13T09:54:14-07:00
Authentication code: 6789

PerlMagick make has 6 errors: syntax, permissions, bad exec format

Post by BrianP007 » 2018-06-09T14:46:58-07:00

Installed ImageMagick-7.0.7-38 on opensuse leap 42.3, gcc-7, all 86 tests report PASS, display works, all appears fine
brianp@trex:~/download/image/image.magick/ImageMagick-7.0.7-38> ./configure --with-modules --with-perl > im.conf.1.log 2>&1
brianp@trex:~/download/image/image.magick/ImageMagick-7.0.7-38> make -j8 > im.make.1.log 2>&1
brianp@trex:~/download/image/image.magick/ImageMagick-7.0.7-38> sudo make install

brianp@trex:~/download/image/image.magick/ImageMagick-7.0.7-38/PerlMagick> identify ../images/logo.jpg
../images/logo.jpg JPEG 123x118 123x118+0+0 8-bit sRGB 18749B 0.000u 0:00.000
brianp@trex:~/download/image/image.magick/ImageMagick-7.0.7-38/PerlMagick> which identify
/usr/local/bin/identify

PerlMagick
I opted for the "create and install a new PERL interpreter with a different name" option (perl.IM) to leave /usr/local/bin/perl alone

There are 6 problems with the PerlMagick install process as documented.
1) Permission error on MYMETA.json << SUDO Install imageMagick leaves it unwritable
2) syntax error in generated CC line:
/bin/sh: L/usr/local/lib64: No such file or directory (see details below)
Makefile.aperl:907: recipe for target 'perl.im' failed
3) After fixing the missing DASH on -L/usr/local/lib64, linking is not done
gcc-7: warning: ./perlmain.o: linker input file unused because linking not done
4) inst_perl must be done as ROOT as it writes to /usr/local, not documented as ImageMagick is
5) inst_perl does not set execute permissions on perl_with_im (perl.im in this case)
6) There is an error in the format
/usr/local/bin/perl.im: cannot execute binary file: Exec format error

The errors are the same without using --with-modules to Configure IM.
The same gcc-7 compiler was used for both Perl and ImageMagick

Could one of the PerlMagick experts there actually execute these 3 steps and show the log files and run the PerlMagick?


=====================================
Gory Details:

cd to PerlMagick directory, follow instructions:
Create NEW Perl with IM and leave the system Perl alone
To install the new 'perl.im' binary, call
make -f Makefile.aperl inst_perl MAP_TARGET=perl.im
make -f Makefile.aperl map_clean

There is a permissions problem, the ROOT install of ImageMagick leaves MYMETA.json' unwritable:
Error opening 'MYMETA.json' for writing: Permission denied

brianp@trex:~/download/image/image.magick/ImageMagick-7.0.7-38> cd PerlMagick/
brianp@trex:~/download/image/image.magick/ImageMagick-7.0.7-38/PerlMagick> perl Makefile.PL MAP_TARGET=perl.im
Warning: -L../MagickCore/.libs changed to -L/home/brianp/sda3/brianp/download/image/image.magick/ImageMagick-7.0.7-38/PerlMagick/../MagickCore/.libs
Warning (mostly harmless): No library found for -lperl
Warning (mostly harmless): No library found for -lperl
ERROR from evaluation of /home/brianp/sda3/brianp/download/image/image.magick/ImageMagick-7.0.7-38/PerlMagick/default/Makefile.PL: Error opening 'MYMETA.json' for writing: Permission denied <<<

Fix permissions error as ROOT and redo
-----------------------------------------------------------------------

Problem 2) syntax error in generated cc line:
brianp@trex:~/download/image/image.magick/ImageMagick-7.0.7-38/PerlMagick> make perl.im >> perl.im.make.log 2>&1

Writing "Makefile.aperl" for this perl.im
Warning: -L../MagickCore/.libs changed to -L/home/brianp/sda3/brianp/download/image/image.magick/ImageMagick-7.0.7-38/PerlMagick/../MagickCore/.libs
Warning (mostly harmless): No library found for -lperl
Generating a Unix-style Makefile.aperl
Writing Makefile.aperl for Image::Magick
Writing MYMETA.yml and MYMETA.json
make -f Makefile.aperl perl.im
make[1]: Entering directory '/home/brianp/sda3/brianp/download/image/image.magick/ImageMagick-7.0.7-38/PerlMagick'
Writing perlmain.c
mv perlmain.ct perlmain.c
cc -c -I../ -I.. -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -I"/usr/include/ImageMagick" -fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -I/usr/include/libpng16 -I/usr/local/include/freetype2 -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libdrm -I/usr/include/libpng16 -I/usr/include/OpenEXR -I/usr/include/openjpeg-2.1 -I/usr/local/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/local/include/freetype2 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -m64 -Ofast -ffast-math -march=native -finline-functions -fopenmp -funroll-loops -flto -Wall -mtune=core2 -fexceptions -pthread -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -O2 -DVERSION=\"7.07\" -DXS_VERSION=\"7.07\" -fPIC "-I/usr/local/lib/perl5/5.26.2/x86_64-linux/CORE" -D_LARGE_FILES=1 -DHAVE_CONFIG_H perlmain.c
L/usr/local/lib64 -fstack-protector -L/usr/local/lib -Wl,-E -O2 ./perlmain.o -o perl.im "/usr/local/lib/perl5/5.26.2/x86_64-linux/CORE/libperl.a" `cat blib/arch/auto/Image/Magick/extralibs.all` -lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
/bin/sh: L/usr/local/lib64: No such file or directory
Makefile.aperl:907: recipe for target 'perl.im' failed

>> /bin/sh: L/usr/local/lib64: No such file or directory
It looks like a dash was lost and replaced with a newline.

Trying this compiles but does NOT LINK:
Fix THIS syntax error:
perlmain.c -L/usr/local/lib64 v << DASH inserted before 'L', newline removed, see below
======================

cc -c -I../ -I.. -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -I"/usr/include/ImageMagick" -fwrapv -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -I/usr/include/libpng16 -I/usr/local/include/freetype2 -I/usr/include/pango-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/libdrm -I/usr/include/libpng16 -I/usr/include/OpenEXR -I/usr/include/openjpeg-2.1 -I/usr/local/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/local/include/freetype2 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -m64 -Ofast -ffast-math -march=native -finline-functions -fopenmp -funroll-loops -flto -Wall -mtune=core2 -fexceptions -pthread -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -O2 -DVERSION=\"7.07\" -DXS_VERSION=\"7.07\" -fPIC "-I/usr/local/lib/perl5/5.26.2/x86_64-linux/CORE" -D_LARGE_FILES=1 -DHAVE_CONFIG_H perlmain.c -L/usr/local/lib64 -fstack-protector -L/usr/local/lib -Wl,-E -O2 ./perlmain.o -o perl.im "/usr/local/lib/perl5/5.26.2/x86_64-linux/CORE/libperl.a" `cat blib/arch/auto/Image/Magick/extralibs.all` -lpthread -lnsl -ldl -lm -lcrypt -lutil -lc >> perl.im.make.log 2>&1

=========================
gcc-7: warning: ./perlmain.o: linker input file unused because linking not done
gcc-7: warning: /usr/local/lib/perl5/5.26.2/x86_64-linux/CORE/libperl.a: linker input file unused because linking not done

========================================
Problem 5) running inst_perl requires SUDO as it writes to /usr/local/bin
make -f Makefile.aperl inst_perl >> perl.im.make.log 2>&1

cp perl.im "/usr/local/bin/perl.im"
Appending installation info to /usr/local/lib/perl5/5.26.2/x86_64-linux/perllocal.pod

============================================

Problem 6), bad exec format:
brianp@trex:~/download/image/image.magick/ImageMagick-7.0.7-38b/PerlMagick> /usr/local/bin/perl.im
-bash: /usr/local/bin/perl.im: cannot execute binary file: Exec format error

Post Reply