检测编译的Perl脚本是否动态加载模块 [英] Detect whether compiled perl script dynamically loads modules
问题描述
我正在使用Strawberry Perl运行Windows 10。我使用 PAR :: Packer 模块制作一些Perl脚本的可执行版本。
I am running Windows 10 with Strawberry Perl. I use the PAR::Packer module to make executable versions of some of my Perl scripts.
我发现一些模块,例如 XML :: LibXML ,需要安装Perl才能运行可执行文件。由于我是在没有Perl的情况下为用户编译这些文件,因此这违反了编译的目的。
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.
在编译之前,有什么方法可以告诉我是否需要使用可执行文件?要运行Perl安装吗?
Is there any way I can tell before compilation whether or not the executable with need a Perl installation to run?
推荐答案
假设您想知道,打包成pp的可执行文件是否可以在没有perl的系统上运行安装后,这是我的操作方法:
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:
从sysinternals.com获取Process Explorer。
打包可执行文件。
运行可执行文件,并在ProcessExplorer
中检查进程的dll( view->显示下部窗格 和 view->下部窗格视图->' DLL's )
如果您看到任何DLL都指向Windows系统中存在的PAR temp-dir或系统库以外的路径,请返回,再次打包并添加这些
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.
示例:
pp -e "use XML::LibXML; while(1){sleep 1}"
正在运行
Process Explorer显示
Running a.exe ...
Process Explorer displays
libxml2-2_.dll ... C:\Users\user\perl522\c\bin\libxml2-2_.dll
这将不会出现在用户系统上...
正在运行pp:
This will not be present on a users system ...
Rerunning pp:
pp -l libxml2-2_.dll -e "use XML::LibXML; while(1){sleep 1}"
这次,运行 a。 exe ...
Process Explorer显示:
This time, running a.exe ...
Process Explorer displays:
libxml2-2_.dll ... C:\Users\user\AppData\Local\Temp\par-xxx\cache-SHA1\libxml2-2_.dll
现在,该过程将拾取与pp捆绑在一起的库,并将其提取到PARs cache-dir。
Now the process picks up the lib that was bundled with pp and extracted to PARs cache-dir.
干杯,克里斯
这篇关于检测编译的Perl脚本是否动态加载模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!