perlparperl-packager

How to pack perl script with all dependencies from Windows to run on linux machine?


I have used pp PAR::Packer to build a standalone exe file to run on a Windows machine.

Can somebody explain how to build a Perl script with all the dependent packages from this Windows machine to create a standalone file to be run on a Linux machine?


Solution

  • Generating a binary that runs on a Linux machine starting from a Windows machine is not possible.



    You use the pp (from PAR-Packer) command probably quite in the same way as you did in Windows

    pp -S -M Some::Module -M Some::Other::Module -o youBinary.bin Script1.pl Script2.pl ScriptN.pl
    

    Things to note:


    Use of runtime loader module Module::Runtime detected.  Results of static scanning may be incomplete.
    Use of runtime loader module Module::Implementation detected.  Results of static scanning may be incomplete.
    

    Be aware also of creating the binary on a machine with an "older" libc. If you do this on a bleeding edge linux, you will need a bleeding edge linux to run it too, making it less portable.

    Note that even if your perl was built with a shared library, the 'Stand-alone executable' above will not need a separate perl5x.dll or libperl.so to function correctly. But even in this case, the underlying system libraries such as libc must be compatible between the host and target machines.

    Enjoy your standalone Perl binary.

    EDIT

    Generating a binary that runs on a Linux machine starting from a Windows machine is not possible.

    The Perl Packager scripts says that it can create executable that runs in same OS. Can I use it to create Win32 binary with linux machine? Or what should I use to create Win32 executable binary on linux from my script?

    It is not possible to create stand-alone binaries for different platform than what you are currently running on. This is a generally hard problem since you would have to cross-compile all XS modules and perl itself. Not nice.

    For example, if you would like to develop an application on Linux and ship it for both Linux/x86 and Win32/x86, it works well to set up a Virtual Machine with a Windows (XP or 2000 or whatever) and a Perl installation. On that machine, use PAR/pp to package your application for Win32.

    On what platforms can I run PAR? On what platforms will the resulting executable run?

    Win32 (95/98/ME/NT4/2K/XP), FreeBSD, Linux, AIX, Solaris, Darwin and Cygwin.

    The resulting executable will run on any platforms that supports the binary format of the generating platform.