perlexemojo

Perl .exe file: Can't call method “encode” on an undefined value


I am begginer of the Perl. I made my Perl script and I want to make a Perl script into a self-contained executable. To create .exe file I used PAR::Packer. After creating and executing .exe file I get such error:

  Can't call method "encode" on an undefined value at Win32/Unicode/Util.pm line 36, <DATA> line 2125.
    Compilation failed in require at Win32/Unicode.pm line 14, <DATA> line 2125.
    BEGIN failed--compilation aborted at Win32/Unicode.pm line 14, <DATA> line 2125.
    Compilation failed in require at if.pm line 13, <DATA> line 2125.
    BEGIN failed--compilation aborted at App/Weryfikacja/Term.pm line 7, <DATA> line 2125.
    Compilation failed in require at App/Weryfikacja/Log.pm line 8, <DATA> line 2125.
    BEGIN failed--compilation aborted at App/Weryfikacja/Log.pm line 8, <DATA> line 2125.
    Compilation failed in require at App/Weryfikacja.pm line 17, <DATA> line 2125.
    BEGIN failed--compilation aborted at App/Weryfikacja.pm line 17, <DATA> line 2125.
    Compilation failed in require at script/diagfull.pl line 54, <DATA> line 2125.
    BEGIN failed--compilation aborted at script/diagfull.pl line 54, <DATA> line 2125.

I want to notice that Perl script runs well. What can cause my .exe file doesn't work? Maybe I need to add modules or something like that to .exe file?


Solution

  • If you could provide the details how you used the pp utility from PAR::Packer, it might be easier for others to provide assistance. Without those details, I'm going to assume that you did something like "pp -o test.exe test.pl".

    The first thing that I would suggest would be to use the -c and/or -x options. Those options are used "to determine additonal run-time dependencies". Keep in mind that those are case-sensitive options.

    If that doesn't fix all of the issues, you may need to use additional options. Check the documentation for the pp utility for more details on the other options.

    Also, I noticed that you added the "mojo" tag to your question, so I'm assuming that your code is using Mojolicious. If that's the case, you may want to check out this blog for some help on creating a stand alone application using Mojolicious.