Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

pp missing module error

by nzsvz9 (Sexton)
on May 27, 2020 at 15:24 UTC ( [id://11117344]=perlquestion: print w/replies, xml ) Need Help??

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

Hello Perl Monks!

Strawberry perl 5, version 30, subversion 1 (v5.30.1) built for MSWin32-x64-multi-thread

pp PAR Packager, version 1.050 (PAR version 1.016)

I have a Tk application which uses GD. The Tk displays the image, and the GD portion is used to resize the image, and interrogate the pixels in the image.

The GD code does snippets include the following:

# Now make a thumbnail the size of the selected SIZE my $thumbnail = new GD::Image($W,$H); # Read in jpg $image = GD::Image->newFromJpeg($IMAGE{'Pathfile'}); # GD $image->copyResized($sourceImage,$dstX,$dstY,$srcX,$srcY,$d +estW,$destH,$srcW,$srcH) $thumbnail->copyResized($image, 0, 0, 0, 0, $W, $H, $IMAGE{'Widt +h'}, $IMAGE{'Height'}); # Get the resized image as a jpg $thumbdata = $thumbnail->jpeg();
The GD code in the perl program works well. Original image is read in, resized, and saved as a thumbnail - as expected.

However, when I "package" the code using pp - I get the following error when I try to use it on a computer that does NOT have perl installed.

Can't load 'C:\Users\nzsvz9\AppData\Local\Temp\par-6576616e63\cache-c9 +a4a6bfb082a4aa29b32277a1db1b29b2e1e568\4efc3f8a.xs.dll' for module GD +: load_file:The specified module could not be found at <embedded>/Dyn +aLoader.pm line 193. at <embedded>/PAR/Heavy.pm line 140. Compilation failed in require at script/myprogram.pl line 11. BEGIN failed--compilation aborted at script/myprogram.pl line 11.
Which to me is the program can't find xs.dll - do I need to explicitly include this in the pp command? If so, how?

BTW: Line 11 is the following not-so-very complex but important line:

use GD;
I have tried several options with pp - to no avail. I tried -M GD.pm and -x but it makes no difference.
pp -o myprogram.exe -x myprogram.pl
There is another potential complication involved, of course. When exiting the perl Tk program I often get the "TK_FreeCursor received unknown cursor argument" which I know to be a problem in the Tk libraries where Tk_Cursor is inconsistent with Tk_FreeCursor (or so I've read) and needs to be fixed - but I don't expect it's contributing to this pp error. Although if someone would fix that - I'd be grateful. Or, if someone would teach me how ... but I digress. My apologies.

Any guidance or wisdom is appreciated that leads me to a solution.

Regards,

nzsvz9 - formerly known as the guy who could fix problems, now known as the guy asking for help with problems :(

And - a quote just to provoke thought:

"There are three ways to spoil a public man: women, gambling, and listening to experts.

The first is the pleasantest, the second is the fastest, but the third is the most certain." ~ Georges Pompidou

Replies are listed 'Best First'.
Re: pp missing module error
by haj (Vicar) on May 27, 2020 at 16:19 UTC

    I guess that the problem is caused by GD.pm's nature as "just" an interface to the GD library. This library comes with Strawberry Perl. I don't have a Windows system available right now, but by looking at sources from an old project I guess that you need to add the library explicitly:

    pp ... --link=libgd-3__.dll

    Verify the name of the DLL, it should be located in Strawberry's c/bin directory.

    Edited: it's --link, not --lib. And yes, that's two underscores.

      I've altered the pp command as follows:
      pp -v --output myprogram.exe --link=C:\Strawberry\c\bin\libgd-3__.dll +--link=C:\Strawberry\perl\vendor\lib\auto\Class\Load\XS\XS.xs.dll myp +rogram.pl
      Still getting the same error.

      I REALLY don't want to have to install perl and libraries on a target computer to run this - people just want an exe to run ...

        Ok, I got hold of two Windows systems... one to build the executable, the other with no Strawberry (such things exist!) to run it. Here's the pp invocation in my .bat file:
        pp --verbose ^ --link=libgd-3__.dll ^ --link=libbz2-1__.dll ^ --link=libgraphite2__.dll ^ --link=libharfbuzz-0__.dll ^ --link=libfreetype-6__.dll ^ --link=libiconv-2__.dll ^ --link=libjpeg-9__.dll ^ --link=liblzma-5__.dll ^ --link=libpng16-16__.dll ^ --link=libtiff-5__.dll ^ --link=libXpm__.dll ^ --link=zlib1__.dll ^ --module=GD ^ --output=gdpacked.exe ^ pack_gd.pl

        The program pack_gd.pl is just the synopsis from GD on metacpan. Running pp produces no error, and running the executable prints a PNG image. So when you run it, remember to redirect the output to a .png file.

        In my first reply, I mixed up some dashes with underscores and missed a few dependencies. Sorry.

        Oh well... The GD library has a few dependencies by itself. Here's a list of suspects:
        • libfreetype_6__.dll
        • libiconv_2__.dll
        • libjpeg_9__.dll
        • libpng16_16__.dll
        • libtiff_5__.dll
        • libXpm__.dll
        • zlib1__.dll

        That's just from the strings in libgd-3__.dll, I can't say whether the list is comprehensive. I'll probably get some time to experiment on my Windows box in a few days.

        As an aside: As far as I can say, You don't need to provide the absolute path to the libraries. pp should find them as they're on pp's path.

Re: pp missing module error
by marto (Cardinal) on May 27, 2020 at 16:17 UTC

    So you tried the -x flag which is usual my first suggestion, ppsimple has saved the day for various people. related. Super Search will likely be helpful.

      Just downloaded ppsimple.pl and I need to install a module (Proc::Background at least) to try this ... but I will. Thanks for the suggestion.

        Sure, but just on the machine doing the packaging.

Re: pp missing module error
by swl (Parson) on May 27, 2020 at 22:16 UTC

    You need to iterate through each dependent DLL using objdump to get the full list. This is automated in pp_simple and pp_autolink, so perhaps give them a try.

    FWIW, I get this set on Strawberry Perl 5.28 for a script that just does use GD; print "1";.

    libiconv-2__.dll zlib1__.dll libbz2-1__.dll libgd-3__.dll libfreetype-6__.dll libpng16-16__.dll liblzma-5__.dll libxpm__.dll libtiff-5__.dll libjpeg-9__.dll

    This is similar to the set provided by haj in 11117362 but missing libgraphite and libharfbuzz, presumably because I used a simpler script.

    Update: I see marto has already provided links to pp_simple and pp_autolink info in 11117346.

Re: pp missing module error
by choroba (Cardinal) on May 27, 2020 at 16:33 UTC
    Have you tried searching for pp dll?
    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
Re: pp missing module error
by Marshall (Canon) on May 27, 2020 at 18:23 UTC
    Often with issues like this, just something like use GD; and perhaps also use GD::Image; will give enough hints to packager to force GD into the .exe.
      Thanks for the idea. I just tried it again with use GD::Image; as well ... same error.

      I know there's an answer out there somewhere!

        Just to be clear, you tried with BOTH: use GD; and use GD::Image?
        Of course, you should have at least use Tk; as well.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11117344]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-19 20:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found