Detect whether compiled perl script dynamically loads modules

426 Views Asked by At

I am running Windows 10 with Strawberry Perl. I use the PAR::Packer module to make executable versions of some of my Perl scripts.

I find that some modules e.g. XML::LibXML, require a Perl installation in order to run the executable. Since I'm compiling these for users without Perl this defeats the purpose of the compilation.

Is there any way I can tell before compilation whether or not the executable will need a Perl installation to run?

1

There are 1 best solutions below

2
On BEST ANSWER

Assuming you want to know, if your pp - packed executable will run on a system with no perl installed, here is how I do it:

Get Process Explorer from sysinternals.com.
Pack your executable.
Run the executable and check the dlls of the process in ProcessExplorer
(view->'show lower pane' and view->'lower pane view'->'DLLs')
If you see any dll refering to a path other than the PAR temp-dir or system libraries, which are present on any windows system, go back, pack again and add these libs using pp's -l switch.

Example:

pp -e "use XML::LibXML; while(1){sleep 1}"

Running a.exe ...
Process Explorer displays

libxml2-2_.dll ... C:\Users\user\perl522\c\bin\libxml2-2_.dll

This will not be present on a users system ...
Rerunning pp:

pp -l libxml2-2_.dll -e "use XML::LibXML; while(1){sleep 1}"

This time, running a.exe ...
Process Explorer displays:

libxml2-2_.dll ... C:\Users\user\AppData\Local\Temp\par-xxx\cache-SHA1\libxml2-2_.dll

Now the process picks up the lib that was bundled with pp and extracted to PARs cache-dir.

Cheers, Chris