在Windows下使用Strawberry Perl將簡單Perl腳本編譯爲可執行文件最簡單的方法是什麼?(據我所知,這可能是免費的)?如何使用Strawberry Perl將Perl腳本編譯爲Windows可執行文件?
以前我用過ActiveState編譯器和perl2exe,很簡單。但是,現在經過幾次計算機更改和操作系統更新,我失去了許可證,我希望找到更好的/永久的解決方案。
在Windows下使用Strawberry Perl將簡單Perl腳本編譯爲可執行文件最簡單的方法是什麼?(據我所知,這可能是免費的)?如何使用Strawberry Perl將Perl腳本編譯爲Windows可執行文件?
以前我用過ActiveState編譯器和perl2exe,很簡單。但是,現在經過幾次計算機更改和操作系統更新,我失去了許可證,我希望找到更好的/永久的解決方案。
安裝PAR::Packer from CPAN (it is free)並使用pp工具。
使用說明:http://n3ncy.com/PERL/和here:http://stackoverflow.com/questions/1237286/how-can-i-compile-my-perl-腳本那麼它可任意被執行的上的系統,而無需-perl的入/ 124137 9#1241379 – Notitze 2010-06-01 10:45:03
注意:PAR :: Packer/pp附帶手冊:http://search.cpan.org/perldoc?pp要深入瞭解您可以用PAR做什麼,請查看我的來自YAPC :: EU 2008的講話http://steffen-mueller.net/talks/appdeployment/ – tsee 2010-06-01 16:13:38
這似乎不適用於我http://stackoverflow.com/questions/9588100/installing-parpacker-on-windows -dmake-error-255 – 2012-03-06 17:24:50
有三種包裝商,以及兩種編譯器:
免費打包:PAR
商業包裝商:perl2exe,perlapp
編譯器:B :: C,B :: CC
http://search.cpan.org/dist/B-C/perlcompile.pod
(注:perlfaq3仍然是錯誤的)
對於你的草莓因爲B-C-1.42不支持5.16,所以需要來自git master(1.43)的perl-5.16和B-C。
這是一步一步的例子,它使用草莓,它的工作原理! 它基於的ExtUtils ::嵌入模塊和perlembed文檔
http://perl-node-interface.blogspot.com/2011/03/deploy-perl-application-on-windows.html
注意:本示例使用ExtUtils :: Embed。我試圖按照說明操作,但並不是所有文件都在示例中完全顯示,我無法完成這項工作。相比之下,使用PAR :: Packer的「pp」示例非常非常簡單,並且首次運行。根據我的經驗,我不得不推薦PAR :: Packer和pp。 – 2012-01-16 00:23:20
:: short answer :
:: perl -MCPAN -e "install PAR::Packer"
pp -o <<DesiredExeName>>.exe <<MyFancyPerlScript>>
:: long answer - create the following cmd , adjust vars to your taste ...
:: next_line_is_templatized
:: file:compile-morphus.1.2.3.dev.ysg.cmd v1.0.0
:: disable the echo
@echo off
:: this is part of the name of the file - not used
set _Action=run
:: the name of the Product next_line_is_templatized
set _ProductName=morphus
:: the version of the current Product next_line_is_templatized
set _ProductVersion=1.2.3
:: could be dev , test , dev , prod next_line_is_templatized
set _ProductType=dev
:: who owns this Product/environment next_line_is_templatized
set _ProductOwner=ysg
:: identifies an instance of the tool (new instance for this version could be created by simply changing the owner)
set _EnvironmentName=%_ProductName%.%_ProductVersion%.%_ProductType%.%_ProductOwner%
:: go the run dir
cd %~dp0
:: do 4 times going up
for /L %%i in (1,1,5) do pushd ..
:: The BaseDir is 4 dirs up than the run dir
set _ProductBaseDir=%CD%
:: debug echo BEFORE _ProductBaseDir is %_ProductBaseDir%
:: remove the trailing \
IF %_ProductBaseDir:~-1%==\ SET _ProductBaseDir=%_ProductBaseDir:~0,-1%
:: debug echo AFTER _ProductBaseDir is %_ProductBaseDir%
:: debug pause
:: The version directory of the Product
set _ProductVersionDir=%_ProductBaseDir%\%_ProductName%\%_EnvironmentName%
:: the dir under which all the perl scripts are placed
set _ProductVersionPerlDir=%_ProductVersionDir%\sfw\perl
:: The Perl script performing all the tasks
set _PerlScript=%_ProductVersionPerlDir%\%_Action%_%_ProductName%.pl
:: where the log events are stored
set _RunLog=%_ProductVersionDir%\data\log\compile-%_ProductName%.cmd.log
:: define a favorite editor
set _MyEditor=textpad
ECHO Check the variables
set _
:: debug PAUSE
:: truncate the run log
echo date is %date% time is %time% > %_RunLog%
:: uncomment this to debug all the vars
:: debug set >> %_RunLog%
:: for each perl pm and or pl file to check syntax and with output to logs
for /f %%i in ('dir %_ProductVersionPerlDir%\*.pl /s /b /a-d') do echo %%i >> %_RunLog%&perl -wc %%i | tee -a %_RunLog% 2>&1
:: for each perl pm and or pl file to check syntax and with output to logs
for /f %%i in ('dir %_ProductVersionPerlDir%\*.pm /s /b /a-d') do echo %%i >> %_RunLog%&perl -wc %%i | tee -a %_RunLog% 2>&1
:: now open the run log
cmd /c start /max %_MyEditor% %_RunLog%
:: this is the call without debugging
:: old
echo CFPoint1 OK The run cmd script %0 is executed >> %_RunLog%
echo CFPoint2 OK compile the exe file STDOUT and STDERR to a single _RunLog file >> %_RunLog%
cd %_ProductVersionPerlDir%
pp -o %_Action%_%_ProductName%.exe %_PerlScript% | tee -a %_RunLog% 2>&1
:: open the run log
cmd /c start /max %_MyEditor% %_RunLog%
:: uncomment this line to wait for 5 seconds
:: ping localhost -n 5
:: uncomment this line to see what is happening
:: PAUSE
::
:::::::
:: Purpose:
:: To compile every *.pl file into *.exe file under a folder
:::::::
:: Requirements :
:: perl , pp , win gnu utils tee
:: perl -MCPAN -e "install PAR::Packer"
:: text editor supporting <<textEditor>> <<FileNameToOpen>> cmd call syntax
:::::::
:: VersionHistory
:: 1.0.0 --- 2012-06-23 12:05:45 --- ysg --- Initial creation from run_morphus.cmd
:::::::
:: eof file:compile-morphus.1.2.3.dev.ysg.cmd v1.0.0
這是什麼語法? – 2012-06-23 11:57:56
windows cmd/batch – 2012-06-23 14:17:04
愚弄http://stackoverflow.com/questions/1237286和http://stackoverflow.com/questions/446685 – daxim 2010-06-01 09:09:22
可能[如何在不安裝解釋器的情況下部署Perl/Python/Ruby腳本?](http://stackoverflow.com/questions/446685/how-can-i-deploy-a-perl-python-ruby-script -without-installation-an-interpreter) – 2010-12-28 19:02:35