- probably your user don't know Perl exists
- your user uses Windows
- your user want just to click on a .exe to launch your program
What you will read it worked for me, feel free to improve it, adapt it to fit your needs and/or automate it as you like.
The only requirement needed is Strawberry Perl.Let's define some names so I can explain with my example how to deploy your Perl program on Windows: my program is called pni.exe, has a red mushroom icon,
and it is based on a CPAN module I wrote, called PNI::GUI::Tk.
PNI stands for Perl Node Interface, and PNI::GUI::Tk is a Tk based GUI for PNI with a pniguitk.pl script to launch it. It is really similar to a so called App, except that it is not under the App:: namespace.
Prepare to build you Perl app
First of all, get a Windows machine, ( this is the most difficult part for a lot of people that is allergic to Microsoft :-) then install the Strawberry Perl distribution, it is a really good way to feel unix-like on Windows.
cpan PNI::GUI::Tkto install the module and its dependencies that are Tk, PNI::Node::Tk and the PNI core module.
Now create a folder, called for instance PerlNodeInterface-windows-0.11, put the pniguitk.pl script inside, a README.txt file to be kind ( don't forget the .txt extension, since you are on Windows ) and a lib folder containing all dependencies. This is how it looks like, see below how to compile pni.exe.
There is a pniguitk.pl which launches the app:
#! env perl
my $app = PNI::GUI::Tk::App->new;
Don't forget the auto folder for Tk since it is an XS module.
The dir tree it looks something like this:
Everything was there, from the beginning
Yes, but you know, most of the people in the world never typed
perldoc ExtUtils::EmbedI started from there, and I found all the informations to compile pni.exe ... so here we go!
perl -MExtUtils::Embed -e xsinitwill produce perlxsi.c, rename it pni.c and add a main function, like the interp.c from
perldoc perlembedThen change the arguments in the main function and hardcode a -Ilib and the name of the script .
Something like this :
//argv stores the relative path of the executableargv = "-Ilib";//argv is for programfileargv = "pniguitk.pl";
Get a cool mushroom icon :-) and create a text file pni.rc containing this line
ID ICON "pni.ico"then launch
windres pni.rc -o coff -o pnirc.oNow you can compile pni.exe with gcc using options
-Wall -mwindows -o pni pnirc.o pni.cand options coming from the output of
perl -MExtUtils::Embed -e ccoptsand
perl -MExtUtils::Embed -e ldopts
You can automate compilation with few lines of code:
use ExtUtils::Embed;use PNI;print "\nBuilding PNI $PNI::VERSION\n";my $gcc_cmd = join( ' ' , 'gcc -Wall -mwindows -o pni pnirc.o pni.c' , &ccopts , &ldopts );print STDOUT $gcc_cmd , "\n";system( $gcc_cmd );
Finally zip your folder, since zip is supported natively on Windows, and you will get a PerlNodeInterface-windows-0.11.zip ready for an user-friendly deploy.
If this procedure works and make sense for most of the perlish folks, Trawberry Perl could become a sort of JRE for Perl on Windows.
There are a lot of users out there that need our Perl programs, but they don' t need all the complexities behind.