简体   繁体   English

如何打包我的Perl脚本以在没有Perl的机器上运行?

[英]How can I package my Perl script to run on a machine without Perl?

People also often ask "How can I compile Perl?" 人们也经常会问“如何编译Perl?” while what they really want is to create an executable that can run on machines even if they don't have Perl installed. 而他们真正想要的是创建一个可以在机器上运行的可执行文件,即使他们没有安装Perl。

There are several solutions, I know of: 我知道有几种解决方案:

  1. perl2exe of IndigoStar It is commercial. IndigoStar的perl2exe它是商业的。 I never tried. 我从未尝试过。 Its web site says it can cross compile Win32, Linux, and Solaris. 它的网站说它可以交叉编译Win32,Linux和Solaris。
  2. Perl Dev Kit from ActiveState. 来自ActiveState的Perl Dev Kit It is commercial. 它是商业的。 I used it several years ago on Windows and it worked well for my needs. 几年前我在Windows上使用它,它可以很好地满足我的需求。 According to its web site it works on Windows, Mac OS X, Linux, Solaris, AIX and HP-UX. 根据其网站,它适用于Windows,Mac OS X,Linux,Solaris,AIX和HP-UX。
  3. PAR or rather PAR::Packer that is free and open source. PAR或者更确切地说PAR :: Packer是免费和开源的。 Based on the test reports it works on the Windows, Mac OS X, Linux, NetBSD and Solaris but theoretically it should work on other UNIX systems as well. 基于测试报告,它可以在Windows,Mac OS X,Linux,NetBSD和Solaris上运行,但理论上它也可以在其他UNIX系统上运行。 Recently I have started to use PAR for packaging on Linux and will use it on Windows as well. 最近我开始在Linux上使用PAR进行打包,并且也将在Windows上使用它。

Other recommended solutions? 其他推荐解决方案

In addition to the three tools listed in the question, there's another one called Cava Packager written by Mark Dootson, who has also contributed to PAR in the past. 除了问题中列出的三个工具之外,还有另一个名为Cava Packager的人 ,由Mark Dootson编写,他过去也曾为PAR做过贡献。 It only runs under Windows, has a nice Wx GUI and works differently from the typical three contenders in that it assembles all Perl dependencies in a source / lib directory instead of creating a single archive containing everything. 它只能在Windows下运行,有一个很好的Wx GUI,与典型的三个竞争者的工作方式不同,因为它汇集源/ lib目录中的所有Perl依赖项,而不是创建包含所有内容的单个存档。 There's a free version, but it's not Open Source. 有一个免费版本,但它不是开源的。 I haven't used this except for testing. 我没有用过这个,除了测试。

As for PAR, it's really a toolkit. 至于PAR,它确实是一个工具包。 It comes with a packaging tool which does the dependency scanning and assembly of stand-alone executables, but it can also be used to generate and use so-called .par files, in analogy to Java's JARs. 它附带了一个打包工具,可以执行独立可执行文件的依赖项扫描和组装,但它也可以用来生成和使用所谓的.par文件,类似于Java的JAR。 It also comes with client and server for automatically loading missing packages over the network, etc. The slides of my PAR talk at YAPC::EU 2008 go into more details on this. 它还带有客户端服务器,用于通过网络自动加载丢失的软件包等。我YAPC :: EU 2008上的PAR演讲幻灯片详细介绍了这一点。 There's also an active mailing list: par at perl dot org. 还有一个活跃的邮件列表:parl at perl dot org。

It is some time since this question was first asked, but Cava Packager can currently produce executable packages for Windows, Linux and Mac OS X. It is no longer Windows only. 这个问题首次被问到已经有一段时间了,但是Cava Packager目前可以为Windows,Linux和Mac OS X生成可执行程序包。它不再仅仅是Windows。

Note: As indicated by my name, I am affiliated with Cava Packager. 注意:正如我的名字所示,我与Cava Packager有联系。

I'm a Perl newbie and I just downloaded Cava Packager and that's the only one I found working. 我是Perl新手,我刚下载了Cava Packager,这是我发现的唯一一个。 I've tried ActiveState 5.10.1005 and Strawberry Perl with PAR-Packager on Windows XP. 我在Windows XP上尝试过ActiveState 5.10.1005和带有PAR-Packager的Strawberry Perl。 pp just hangs in mid-stream and no executables created. pp只是在流中挂起而没有创建可执行文件。

Cava provides the only solution to creating exe on Windows so far. 到目前为止,Cava提供了在Windows上创建exe的唯一解决方案。 Thks. THKS。

You could use the perlcc tool that's shipped with most distributions of Perl. 您可以使用大多数Perl发行版附带的perlcc工具。 I've also found both perl2exe and Active State's Perl Dev kit useful for shipping Perl applications. 我还发现perl2exe和Active State的Perl开发工具包对于运送Perl应用程序非常有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM