What is the correct invocation of pp to pack this directory structure?

138 views Asked by At

I know there are two other questions that hit at the same thing here but mine comes from actually trying the suggestions there, and in hope that there are some other options that have worked for people since then.

The setup is this: I have an application with multiple modules that I want to share with someone that's on a Windows machine with a Strawberry Perl distro installed.

The structure of it is something like this:

PerlApp
 lib
   Base
     Base.pm
     Gui.pm
   Db
     Db.pm
     records.db
   Parser
     Parser.pm
   Utils
     Utils.pm
 PerlApp.pl
 Config.txt

All this has two points of entry. I can run it either through the cmd line interface with the PerlApp.pl script or run the Gui.pm file that contains a Wx interface for it.

I'm running Strawberry Perl with several modules installed from CPAN that are used by this program. I tried using Cava Packager, unfortunately it doesn't support the version of perl that I developed this with.

I've tried pp but the executable that resulted from packaging the cmd script results in various errors. I consulted the documentation but for the life of me I can't figure out how to use this module to package a full directory tree or if that is even supported. (phonebook documentation syndrome)

I tried

pp -o app.exe PerlApp.pl

The errors are:

The locale codeset (cp1252) isn't one that perl can decode, stopped at Encode/Locale.pm line 94
Compilation failed in require at LWP/UserAgent.pm line 1000
Compilation failed in require at lib/Base/Base.pm line 9

The last resort solution is packaging all the files needed and figuring out what CPAN modules need to be installed on the external machine to make it work and eventually asking the user to install them manually himself.

1

There are 1 answers

0
hajimuz On

I used to have a similar error related to charset (or code page on Windows) when I packed a perl script. I googled everywhere but didn't find any direct answer, but eventually I figured it out by myself.

  1. Actually the Encode module is able to decode cp1252, the real problem is that Encode::Locale determines the appropriate charset at RUNTIME but PP just adds necessary dependencies at the compile time( If I may say ). So you need to add -x option in the command for adding runtime dependencies.
  2. Avoid Encode::Locale completely. Even you pack necessary decoder pm into your executable, when it's run on another system with different charset, the similar error will occur. I suggest you find out which line of your code uses Encode::Locale and figure out a workaround.