Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Cannot save all image formats after compiled to exe

by CKEQvc (Novice)
on Dec 28, 2020 at 13:01 UTC ( [id://11125867]=perlquestion: print w/replies, xml ) Need Help??

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

Hello all,

I am writing an app using Imager and Imager::QRCode, but I am stuck after compiled it to exe using pp.

In StrawberryPerl, all image formats are saved.
However, after compiled to exe, not all image formats saved (i.e. indicated by 0 KB).

I got errors: "Uninitialized value".

For simplicity, my code is similar like below.

Could you point me where part is wrong?

use strict; use warnings; use diagnostics; use Imager; use Imager::QRCode; my $qrcode = Imager::QRCode->new ( size => 2, margin => 2, version => 1, level => 'M', casesensitive => 1, lightcolor => Imager::Color->new(255, 255, 255), darkcolor => Imager::Color->new(0, 0, 0), ); my $img = $qrcode->plot('test'); my @type = ('jpeg', 'png', 'gif', 'tiff', 'bmp', 'pnm', 'raw', 'sgi', +'tga'); for (@type) { open IMAGE, '>', 'image.'.$_ or die $!; binmode IMAGE or die $!; print IMAGE $img->write(fh => \*IMAGE, type =>$_) or die $!; } close IMAGE or die $!;

Replies are listed 'Best First'.
Re: Cannot save all image formats after compiled to exe
by salva (Canon) on Dec 28, 2020 at 15:41 UTC
    That probably means some DLL is not being included inside the .exe file.

    You can try to identify which one is missing monitoring the application with Process Monitor or some similar tool.

    Also, take a look at Win32::Packer (even if I, the author, have not been giving it much attention lately). It allows one to create installers for Windows applications with all its dependencies and it is able to detect automatically DLL dependencies (something pp does not do).

Re: Cannot save all image formats after compiled to exe
by marto (Cardinal) on Dec 28, 2020 at 13:05 UTC

    You don't say how you packaged this with pp, I suspect that pp -x or ppsimple would be worth a shot.

        Either try the linked ppsimple, or unzip the exe/make pp verbose to figure out what is missing.

Re: Cannot save all image formats after compiled to exe
by swl (Parson) on Dec 29, 2020 at 05:32 UTC

    There might be some lazy loaded modules in the Imager or Imager::QRCode modules.

    What happens when you explicitly load all modules under the Imager namespace? This can be done with the -M flag, for example:

    pp -x -M Imager:: -o imager.exe imager.pl

    After running that on my machine I end up with several extra pm files under the Imager dir in the packed executable.

    I have not tried testing if it works, though.

      It works!

      Thank you very much!

      So, I missed -M Imager:: in my pp option.

      Thank you all...

Re: Cannot save all image formats after compiled to exe
by perlfan (Vicar) on Dec 28, 2020 at 18:04 UTC
    Take a look at the Makefile.PL to see what Imager needs in terms of object libraries, this might help you narrow it down. There seems to be quite a bit of compiled objects that it relies on.
Re: Cannot save all image formats after compiled to exe
by CKEQvc (Novice) on Dec 29, 2020 at 00:27 UTC

    Assumed I missed any required file, I have just added files and still no effect, except the exe file becomes bigger:

    pp test.pl -o test.exe -a "C:\Strawberry" -c -x

    Did you test my code and packaged to exe using pp in your computer?
    Succeed? Failed?
    If failed, what you did to fix it?

    I think the answer like that more helpful to me rather than provide hints about what is missing, etc.

      It may help if you tell us what formats don't work for you. It may also help if you tell us what versions of Perl and Imager you are using.

      Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

        Hope these information enough.

        Perl v5.32.0
        Imager v1.012
        Imager::QRCode v0.035

        Saved image formats: BMP, RAW, TGA, PNM.
        Other formats are not saved.

Re: Cannot save all image formats after compiled to exe
by CKEQvc (Novice) on Dec 29, 2020 at 10:09 UTC

    SOLVED

    Thank you all...

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2024-03-28 12:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found