On Fri, Feb 17, 2012 at 13:33, RAPPAZ Francois <francois.rap...@unifr.ch> wrote:
> I did this:
> - pp -B --lib c:\strawberry\perl\vendor\lib -l 
> "C:\strawberry\perl\site\lib\auto\Cairo\Cairo.dll" -l 
> "C:\strawberry\perl\site\lib\auto\Pango\Pango.dll" -l 
> "C:\strawberry\perl\site\lib\auto\Glib\Glib.dll" -l 
> "C:\strawberry\perl\site\lib\auto\Gtk2\Gtk2.dll" -o invtot_l.par invtot.pl
> - unzip the par files
> - removed the lib/auto/Gtk2, lib/auto/Cairo lib/auto/Pango from the par 
> unzipped directory
> - copied the glade folder which contains my glade generated files in the 
> script directory
> - zipped all the directory tree back into invtot.par
> - pp -o invtot.exe invtot.par
>
> Now the .exe file run on my pc if it is located in the same folder as the 
> original script.

I was a bit puzzled why this works :)

It's because of a little known feature of DynaLoader.pm:
When asked to load the "glue" DLL for module Foo::Bar DynaLoader will
usually look
for a file named "auto\Foo\Bar\Bar.dll" below any directory in @INC.
PAR::Packer extends this search to look for this path also in the zip
that is part of the packed executable. Now you effectively removed these paths
from the packed executable, so this fails. In a last ditch effort DynaLoader
simply punts and asks the OS to load "Bar.dll" (i.e. using its usual
search strategy,
on Windows that means looking in the directories in PATH).

Every DLL you add to the packed executable with "pp -l ..." is flatly packed in
the zip in directory shlib/ARCH and unconditionally extracted in the cache area.
Also the packed executable runs with the cache directory prepended to PATH.
So when asked to load the glue DLL for Gtk2.pm etc, DyneLoader loads Gtk2.dll
from the cache directory. That way we get rid of the second copy of the DLLs
(extracted and loaded with mangled names) and inter-DLL symbol references
work as expected.

> On an other pc, first the exe failed complaining it missed a libglib-2.0-0.dll
> I setup Gtk+ runtime from http://sourceforge.net/projects/gtk-win/
> Now the line "use Gtk2 -init;" seems to pass.

You may add  libglib-2.0-0.dll etc to the packed executable as well and then
you won't need to install it on the target machine. Simply add all DLLs
in your Gtk-for-Win32 bin directory with "pp -l ...".

Cheers, Roderich

Reply via email to