Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

How to convert bunch of perl file + other dependent Input files Into a single executable

by rockyurock (Acolyte)
on Mar 02, 2017 at 07:10 UTC ( [id://1183354]=perlquestion: print w/replies, xml ) Need Help??

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

I am able to convert .pl file Into .exe file using below Perl2Exe from :
http://www.indigostar.com Perl2Exe but failed as well.

I want to Include some dependency files (Input for this .exe) as well In to the same .exe. Is there any way to perform this Operation ?

  • Comment on How to convert bunch of perl file + other dependent Input files Into a single executable

Replies are listed 'Best First'.
Re: How to convert bunch of perl file + other dependent Input files Into a single executable
by marto (Cardinal) on Mar 02, 2017 at 07:36 UTC

    I suggest using pp, to include dependencies in your packaged executable, do:

    pp -x scriptname.pl -o exename.exe

    perl2exe is not open source, read the licence documentation. The docs also show the arcane way of including dependencies.

        I think you misread my post, IMHO perl2exe has an arcane method for including modules, not pp, which I recommend.

      I used this command but It's giving me the below error :

      C:\Users\MTK06729\AppData\Local\Temp\parlC3TX.exe: Perl lib version (5.24.1) doe sn't match executable 'perl.exe' version (5.24.0) at C:/Perl64/lib/Config.pm lin e 62. Compilation failed in require at C:/Perl64/lib/Errno.pm line 10. BEGIN failed--compilation aborted at C:/Perl64/lib/Errno.pm line 10. Compilation failed in require at C:/Perl64/lib/File/Temp.pm line 17. BEGIN failed--compilation aborted at C:/Perl64/lib/File/Temp.pm line 17. Compilation failed in require at C:/Perl64/lib/Archive/Zip.pm line 11. BEGIN failed--compilation aborted at C:/Perl64/lib/Archive/Zip.pm line 11. Compilation failed in require at -e line 240. C:\Perl64\site\bin/pp: Failed to extract a parl from 'PAR::StrippedPARL::Static' to file 'C:\Users\MTK06729\AppData\Local\Temp\parlFZqv5lw.exe' at C:/Perl64/sit e/lib/PAR/Packer.pm line 1184, <DATA> line 1.

        How did you install pp? What does perl -MPAR::Packer -le "print $PAR::Packer::VERSION" return?

Re: How to convert bunch of perl file + other dependent Input files Into a single executable
by marioroy (Prior) on Mar 03, 2017 at 05:58 UTC

    Updated on August 23, 2017.

    Greetings, rockyurock.

    The following are cross-platform templates I share with folks, requesting how to compile a Perl script to an executable for MCE and MCE::Hobo. Making an executable is possible with the PAR::Packer module. On the Windows platform, threads, threads::shared, and exiting via threads are necessary for the binary to exit successfully.

    In regards to module dependencies, one way is to include them at the top of the script.

    # https://metacpan.org/pod/PAR::Packer # https://metacpan.org/pod/pp # # pp -o demo.exe demo.pl # ./demo.exe use strict; use warnings; use if $^O eq "MSWin32", "threads"; use if $^O eq "MSWin32", "threads::shared"; # Include minimum dependencies for MCE. # Add other modules required by your application here. use Storable (); use Time::HiRes (); # use Sereal (); # optional, for faster serialization use MCE; my $mce = MCE->new( max_workers => 4, user_func => sub { print "hello there from ", MCE->wid(), "\n"; } ); $mce->run(); threads->exit(0) if $INC{"threads.pm"};

    MCE workers above spawn as threads whenever threads is present. Unlike MCE, MCE::Hobo workers can only run as child processes, spawned via fork. To work around PAR or a dependency not being multi-process safe, one must run inside a thread on the Windows platform or the exe will crash.

    # https://metacpan.org/pod/PAR::Packer # https://metacpan.org/pod/pp # # pp -o demo.exe demo.pl # ./demo.exe use strict; use warnings; use if $^O eq "MSWin32", "threads"; use if $^O eq "MSWin32", "threads::shared"; # Include minimum dependencies for MCE::Hobo. # Add other modules required by your application here. use Storable (); use Time::HiRes (); # use IO::FDPass (); # optional: for condvar, handle, queue # use Sereal (); # optional: for faster serialization use MCE::Hobo; use MCE::Shared; # For PAR to work on the Windows platform, one must include manually # any shared modules used by the application. # use MCE::Shared::Array; # for MCE::Shared->array # use MCE::Shared::Cache; # for MCE::Shared->cache # use MCE::Shared::Condvar; # for MCE::Shared->condvar # use MCE::Shared::Handle; # for MCE::Shared->handle, mce_open # use MCE::Shared::Hash; # for MCE::Shared->hash # use MCE::Shared::Minidb; # for MCE::Shared->minidb # use MCE::Shared::Ordhash; # for MCE::Shared->ordhash # use MCE::Shared::Queue; # for MCE::Shared->queue # use MCE::Shared::Scalar; # for MCE::Shared->scalar # Et cetera. Only load modules needed for your application. use MCE::Shared::Sequence; # for MCE::Shared->sequence my $seq = MCE::Shared->sequence( 1, 9 ); sub task { my ( $id ) = @_; while ( defined ( my $num = $seq->next() ) ) { print "$id: $num\n"; sleep 1; } } sub main { MCE::Hobo->new( \&task, $_ ) for 1 .. 3; MCE::Hobo->waitall(); } # Main must run inside a thread on the Windows platform or workers # will fail duing exiting, causing the exe to crash. The reason is # that PAR or a dependency isn't multi-process safe. ( $^O eq "MSWin32" ) ? threads->create(\&main)->join() : main(); threads->exit(0) if $INC{"threads.pm"};

    Kind regards, Mario.

      Okk Thank you! But Still I did not get how It can help me to make the .exe on windows. Do I need to Include It my program as when I execute It stand alone It's givnig me below Error :
      Can't locate IO/FDPass.pm in @INC (you may need to install the IO::FDP +ass module ) (@INC contains: C:/Perl64/site/lib C:/Perl64/lib .) at E:\Automation + Related\P erl Scripts - ALL\IMS_debugging\Perl_to_Exe\P2E.pl line 16. BEGIN failed--compilation aborted at E:\Automation Related\Perl Script +s - ALL\IM S_debugging\Perl_to_Exe\P2E.pl line 16.
      Also I think PAR::Packer is already Installed on my system as when I tried -> ppm install PAR::Packer it showed Downloading ActiveState Package Repository dbimage...not modified No missing packages to install

        The modules or dependencies must be available in Perl. Remove the dependencies not needed, including MCE if not used. Basically, add only dependencies required by your application.

Re: How to convert bunch of perl file + other dependent Input files Into a single executable
by Anonymous Monk on Mar 02, 2017 at 07:33 UTC
    If such a feature is supported it will be documented (hint, check the docs)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1183354]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-16 16:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found