perlfan has asked for the wisdom of the Perl Monks concerning the following question:

I have come with a question! Basic set up is: The problem: following the prescribed steps (e.g, setting MAGICK_HOME) and using --with-perl, making sure the perl I want is provided by the perlbrew environment as expected, there is an issue with the build process finding -lperl. I have noted the following: If I install libperl-dev via apt-get, it all works perfectly. This just feels wrong to me. Anyone ever deal with this? I do not get the same issues on Ubuntu doing anything special with perlbrew or passing in anything via --with-perl-options. Though it now occurs to me that I didn't ensure that libperl-dev was not installed as a dependency for something else.

I've been pouring over https://imagemagick.org/script/advanced-linux-installation.php for the better part of a day, and no luck. I also found https://legacy.imagemagick.org/discourse-server/viewtopic.php?t=8133, but it's a very old post and didn't seem to give me any good ideas.

My last resort is to, apt-get install libperl-dev - but I still want to use the newer version of perl provided by perlbrew. Any ideas? I can provide more detailed errors, but was hoping this could be recognized by someone here. TIA.

Replies are listed 'Best First'.
Re: building PerlMagick with perlbrew provided perl on Debian
by arpad.szasz (Pilgrim) on Mar 28, 2021 at 18:06 UTC

    I found a personal note regarding troubleshooting something similar a while back (and a patch against ImageMagick-6.9.1-1) which replaces -lperl with -L' . $Config{'archlib'} . '/CORE'; in the $LIBS_magick scalar variable declaration in the following files:

    • ImageMagick-6.9.1-1/PerlMagick/default/Makefile.PL.in
    • ImageMagick-6.9.1-1/PerlMagick/Makefile.PL.in
    • ImageMagick-6.9.1-1/PerlMagick/quantum/Makefile.PL.in

    For example the diff for PerlMagick/Makefile.PL.in should look like:

    -my $LIBS_magick = '-L../magick/.libs -lMagickCore-@MAGICK_MAJOR_VERSION@.@MAGICK_ABI_SUFFIX@ -lperl @MATH_LIBS@';
    +my $LIBS_magick = '-L../magick/.libs -lMagickCore-@MAGICK_MAJOR_VERSION@.@MAGICK_ABI_SUFFIX@ @MATH_LIBS@ -L' . $Config{'archlib'} . '/CORE';
    

    Hope this works for ImageMagick 7 too.

    I believe the main issue is that the default behaviour is influenced by the LD_LIBRARY_PATH environment variable which wouldn't include the path to your perlbrew built perl library so the system libperl is used.

    You can also try (untested solution) to set LIBRARY_PATH to point to your perlbrew built libperl path before compiling.

      This absolutely work! Thank you so much. I will see if I can get a patch submitted upstream to pay your goodwill forward.
Re: building PerlMagick with perlbrew provided perl on Debian
by 1nickt (Canon) on Mar 28, 2021 at 12:26 UTC

    Hi, FWIW (?) I am running 5.32.0 via perlbrew but I see libperl5.30/focal,now 5.30.0-9build1 amd64 [installed,upgradable to: 5.30.0-9ubuntu0.2] is installed. I definitely did not install that manually.

    Hope this helps!


    The way forward always starts with a minimal test.
      Thank you, this is helpful in explaining part of the situation. I will add that the PerlMagick/Makefile created during the configure and build process of ImageMagick/PerlMagick most definitely accounts for the paths associated with the perlbrew perl, including variables like PERL_INC, etc.

      The path to the architecturally dependent libperl.a in the proper "/CORE" directory is even properly detected and in the PerlMagick/Makefile. If anything, it seems that the linker step is not using that information - - might have something with the following environmental variables not being respected somehow: LDFLAGS, LD_LIBRARY_PATH, LD_RUN_PATH - possible another few that are linker related.

      This may also point to the need to run /usr/bin/ldconfig at some point on either the custom ImageMagick lib path(s) or perl's, which then tells me there might be some assumption being made my ImageMagick's build infrastructure that is being violated by the introduction of perlbrew - or at least a non-privileged build of perl more generally. I'll keep poking at it, but in the mean time I'll probably just apt-get install libperl-dev this and move along.