rschupp / PAR-Packer

(perl) Generate stand-alone executables, perl scripts and PAR files https://metacpan.org/pod/PAR::Packer
Other
48 stars 13 forks source link

Can't load '%TMP%\par-6a6f6b\cache-1234567890abcdef\123456789.xs.dll' for module X::Y::Z #75

Closed hoppfrosch closed 1 year ago

hoppfrosch commented 1 year ago

Hi there,

I compiled a quite complex Perl Script via pp.bat on a reference machine. Running the produced exe on a few different computers was successfull - whilst on most other computers execution of compiled exe failed due to an error

The error message during execution is as follows:

Can't load 'C:\Users\XXX\AppData\Local\Temp\par-6a6f6b\cache-796f45c9f359ff639862f1260cfe0060cbe429a0\1dfc9682.xs.dll' for module XML::Parser::Expat: load_file:The specified module could not be found at <embedded>/DynaLoader.pm line 193.
  at <embedded>/PAR/Heavy.pm line 140.
Compilation failed in require at C:\Users\xxx\AppData\Local\Temp\par-6a6f6b\cache-796f45c9f359ff639862f1260cfe0060cbe429a0\inc\lib/XML/Parser.pm line 18.
BEGIN failed--compilation aborted at C:\Users\xxx\AppData\Local\Temp\par-6a6f6b\cache-796f45c9f359ff639862f1260cfe0060cbe429a0\inc\lib/XML/Parser.pm line 22.
Compilation failed in require at C:\Users\xxx\AppData\Local\Temp\par-6a6f6b\cache-796f45c9f359ff639862f1260cfe0060cbe429a0\inc\lib/XML/Twig.pm line 151.
BEGIN failed--compilation aborted at C:\Users\xxx\AppData\Local\Temp\par-6a6f6b\cache-796f45c9f359ff639862f1260cfe0060cbe429a0\inc\lib/XML/Twig.pm line 151.
Compilation failed in require at C:\Users\xxx\AppData\Local\Temp\par-6a6f6b\cache-796f45c9f359ff639862f1260cfe0060cbe429a0\inc\lib/ABC/DEF.pm line 63.
BEGIN failed--compilation aborted at C:\Users\xxx\AppData\Local\Temp\par-6a6f6b\cache-796f45c9f359ff639862f1260cfe0060cbe429a0\inc\lib/ABC/DEFc.pm line 63.
Compilation failed in require at script/ABC.pl line 181.
BEGIN failed--compilation aborted at script/ABC.pl line 181.

The reference machine - where compilation took place - has following parameters:

I used the following command line to compile: pp.bat --execute --lib=..\lib --output=ABC.exe --xargs="-c TmpConfig.xml" ABC.pl

The resulting ABC.exe has a size of approx 15MB.

Running ABC.exe on several windows machines (different OS Versions, some with local Perl installed, some not ...) leads to different results. Whilst execution on a few machines succeeds, exection failed on an most machines due to error above.

What I analyzed/tried yet:

I found no sytematics to distinguish the erroneous machines from succcessful machines.

rschupp commented 1 year ago

Can't load 'C:\Users\XXX\AppData\Local\Temp\par-6a6f6b\cache-796f45c9f359ff639862f1260cfe0060cbe429a0\1dfc9682.xs.dll' for module XML::Parser::Expat: load_file:The specified module could not be found at /DynaLoader.pm line 193. at /PAR/Heavy.pm line 140.

The problem is most likely that module XML::Parser::Expat has an XS part (i.e. .../XML/Parser/Expat/Expat.xs.dll) that is linked against the "real" expat DLL, e.g. libexpat.dll. To confirm, run objdump -ax on the dll from the "Can't load" error message and look for "DLL Name: ...." lines in the output. libexpat.dll comes with Strawberry, but PAR::Packer does not pack it automagically (see https://github.com/rschupp/PAR-Packer/issues/67#issuecomment-1249196382 for a more elaborate explanation), hence the packed executable will work on machines that have Strawberry installed (or have libexpat.dll in their PATH from some other distribution) and fail on others. To fix, either add libexpat.dll manually (with pp --link ...) or use Shawn Laffan's APP::PP::Autolink.

hoppfrosch commented 1 year ago

Following your recommendation, I used Shawn Laffan's APP::PP::Autolink to compile/pack my PerlScript. The newly compiled exe significantly grows in size in comparison to the erroneous one. Looking inside the exe, libexpat.dll is available - as you predicted correctly (libexpat.dll was not available in the erroneous version).

Running the new exe on different machines works as predicted without any flaws ....

Thanky you so much for your fast and helpful answer! You are my hero of the day ;-)