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

Hey

I want to make an executable perl script . I used PAR::Packer but then it is dependent on windows

can we make perl executable , without dependency on windows version

Replies are listed 'Best First'.
Re: Perl Executable
by rjt (Curate) on Aug 06, 2013 at 11:11 UTC

    As others have correctly mentioned, there is no such thing as a platform-independent executable. What you're asking for is not unlike taking a generic roll of wallpaper but then trying to pre-cut one piece of it in advance to fit any wall.

    How are you planning on distributing the executables? Download? CD/DVD/USB drive? Network install? Virus?

    Your two best options, in my opinion, are:

    1. Package up the separate installers per the other suggestions in this thread
    2. If the functionality of your script lends itself to being run from a centralized location, consider making a browser web-app instead. That's the closest you'll come to a truly platform-independent solution that doesn't depend on an existing Perl installation.

    If you go the download route, you can easily offer downloads for each platform, and in most cases, you can take a very good guess at the user's OS by inspecting the User-agent request header. (But use that as the default selection only; the header may be wrong, or users may have reason to download for a different OS.)

    If you go with physical media, you can have an autorun.inf for Windows, and add some magic to the folder for OS X. See this Stackoverflow question on autoplay for OS X and Windows. There's no general autorun for Linux, which I consider a feature. :-)

    For network deployments, it really depends on your deployment method, but generally you'd have parallel methods for each OS at some point in the process.

    Hope this helps.

      I am easily amused, but I find it funny that the request is essentially to take a language which is pointedly not compiled so it can be OS- and hardware- independent, and you wish to compile it without losing that feature which is why it was not compiled in the first place.

      The fading sound of my cackles will surely continue to encourage my teammates at work to select a path to the coffee machine which maintains a safe distance from me.

        So how would you suggest distributing a Perl application to users who: a) do not have the correct version of Perl installed on their machine b) do not have the dependency tree for the Perl application installed on their machine c) do not have a compiler toolchain to build an binary dependencies from source d) do not have the technical knowledge and/or permissions necessary to do a, b, and c Solving the distribution problem is why PAR::Packer exists. Maybe you only run your software on machines that you have root/administrator permissions on, but some of us have to produce distributable packages with no external dependencies. To the OP: you have to build your distribution on each platform you wish to support. PAR::Packer does not have a "cross-compile" capability. The pure Perl portions of your codebase (and dependency tree) won't change, but any XS code or other C libraries you call will need to be compiled on the target architecture and included in the package. pp is pretty good about dependency checking, but you may have to manually link in any binary dependencies (EG pp --link=libfoo.dll ... for Windows, pp --link=libfoo.so .. on Linux) if they live ouside of the $PERL5LIB directory tree. Virtual machines are great for testing bare-metal installs.
Re: Perl Executable (for what OS)
by Anonymous Monk on Aug 06, 2013 at 08:59 UTC
    For what OS? PAR::Packer runs on windows/linux/macintosh, as does http://cavapackager.com/

    You need to build each .exe on the target OS (or in an emulator)

      yes that is what I wish to by pass , is there any way to make it OS independent

        Executables are always OS- and architecture-dependent.

        It was OS-independent before you used PAR::Packer.

        package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name

        yes that is what I wish to by pass , is there any way to make it OS independent

        No, there are no universal binaries