Flame has asked for the wisdom of the Perl Monks concerning the following question:

I was reading through some of the Perl documentation, and I found something that has me a little curious... is it possible to compile a Perl program into a .exe so that people without Perl can use it?

"Wierd things happen, get used to it"

Flame ~ Lead Programmer: GMS
http://gms.uoe.org

Edit kudra, 2001-08-28 Changed title

  • Comment on Is it possible to compile a Perl program into a .exe?

Replies are listed 'Best First'.
Re: Compile PerllApp .exe perl2exe executable?
by mandog (Curate) on Aug 28, 2001 at 10:36 UTC

    Others pointed to perl2exe.com as a place to get a program to create stand alone LINUX and windows executatables from perl scripts.

    this humble node doesn't have a descriptive title but it points to PerlApp, ActiveState's .exe making tool.

    this thread on compiling perl goes into some detail as to why it might not be a good idea.

    My personal experience with PerlApp is limited. The web hosting company we used at the time wanted $20 per module to install additional modules, so I build a standalone .exe Now I realize that I might have been better off modifying @INC to include a path I controlled.

    As chromatic notes in this node, I can imagine building a standalone .exe for use in places where it is not convenient to install perl.

    I can imagine somebody building a whiz bang GUI based utility and putting it on download.com The chances of the utility being used are greatly enhanced if people don't have to install another 20M worth of files over a modem line. There are people who know or care that Perl and C are different and who expect to download everything they need in one package.


    --mandog
Re: Compile?
by clintp (Curate) on Aug 28, 2001 at 06:20 UTC
    Read a little bit deeper, into perlfaq3. Specifically "How can I compile my Perl program into byte code or C?". The answer has a definate anti-compilation slant to it, but it communicates the basic idea.

    If this is for simple distribution purposes, search the net for perl2exe. A nice tool for solving small problems. It's got its own set of issues but it works well enough.

Re: Compile?
by Jazz (Curate) on Aug 28, 2001 at 08:57 UTC
    You can try Perl2Exe, a shareware program that claims to create cross-platform exe files. I've heard that people have had trouble with glob and Tk and that the resulting exe files are (not surprisingly) huge.

    Jasmine

Re: Compile?
by lo_tech (Scribe) on Aug 28, 2001 at 07:11 UTC

    A compiler for Perl is now part of the standard Perl dist, as of Perl 5.005. The compiler allows you to distribute compiled Perl programs in binary form, which enables easy packaging of Perl-based programs without having to depend on the source machine having the correct version of Perl and all of the dependent modules installed.

    I've had some success with perlcc on Unix systems (well, aix and solaris) but havent tried the outlandish.
    I've never attempted to:

  • compile a script on windows (NT 4.0 SP-5) and run it on a different OS (say, Windows NT, SP-6), or
  • run a unix-compiled perl exe on a Windows system.

    I'm not a unix snob, have never professed to be a magician and generally do not wish to start a OS holy war.

    If anyone else has had some success, please post. I'd like to know how and what tools you used for debugging the compiled script.

    I am but an egg. -RAH

Re: Is it possible to compile a Perl program into a .exe?
by ralphie (Friar) on Aug 28, 2001 at 16:06 UTC
    actually, the activestate tool to use is probably perlctrl. i've used it a few times and the resultant exes can get quite large, but if the machine has access to the perl libraries you can compile it that way, which minimizes the exe size. these are, of course, part of the activestate developers kit, which costs money, but i think you can still download a 10-day eval version.
      Why use PerlCtrl? It creates ActiveX controls. I always use PerlApp, which is the one that converts Perl into EXEs. However, both (and more) are available in the PerlDevKit, which can be found at the following link:

      ActiveState Perl Development Kit

      As Ralphie states, it does cost money, and you can get a 10 day eval version. However, Perl2Exe also costs money, you just have a 30 day time period (I believe) and you are not allowed to distribute anything made from Perl2Exe until you have payed for it. Both programs are good, both have drawbacks, but when you need to distribute an EXE due to the fact you don't want other people to install Perl to use your tools, they work.

        Thanks everyone, while it's not the response I hoped for (I was hopeing it was a practical solution to my problem... I can't distribute a program that big... and I would have needed Tk... which seems to have some problems as an exe...)
        I guess all I can do is wait and hope that Perl6 has better compile support... or go learn C/C++/VBasic...

        Thanks again


        "Wierd things happen, get used to it"

        Flame ~ Lead Programmer: GMS
        http://gms.uoe.org
Re: Compile?
by blackjudas (Pilgrim) on Aug 28, 2001 at 06:45 UTC
    As far as I'm aware, no such luck in that department. Though I'd like to see the perl codebase move towards such a feature, mainly because of the fact you state, especially with small installs of Linux which don't have a lot of room to handle a full install of Perl. I haven't really looked into it, though I'm gonna go search now to see if 6.0 has any plans to do this.