2

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.

user3046061
  • 353
  • 4
  • 14
  • `pp` is probably the way to go. If you had problems with its usage, it would be probably best to show us the error messages etc. – ideally a complete, minimal, and runnable example that demonstrates your problem. We can then try to help you with that. We can't help you by pointing to the [`Magic::FairyWand` module v0.42 which will solve all your problems without further effort](https://metacpan.org/pod/Magic::FairyWand), because it doesn't exist. – amon Feb 06 '14 at 12:49
  • My problem with it's usage is that I don't understand its usage. Yes ridiculous I know. Given the structure that I mentioned in the op how would I actually run it to even get a glimpse at the output. I tried the obvious pp -o bla.exe PerlApp.pl. But I highly doubt that's the way, unless pp cleverly looks around in that directory, which is like you said, a FairyWand wish. – user3046061 Feb 06 '14 at 12:54
  • Ah. Maybe you can [edit] your question so that it's more obvious that you're actually asking “*What is the correct invocation of `pp` to pack this directory structure – `some command` didn't work.*” I don't have the necessary knowledge to answer that, but you can make it easier for others who do. – amon Feb 06 '14 at 12:57
  • No problem. I typed in a broader question in hope of getting more input. – user3046061 Feb 06 '14 at 13:03

1 Answers1

1

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.
hajimuz
  • 368
  • 3
  • 14