• Subscribe

    Subscribe to This Week In Panospace by eMail.
    Subscribe in a reader
  • License

    Creative Commons License
    This work is © 2008-2012
    by Yuval Levy
    and licensed under a
    Creative Commons License.
  • Entries

    June 2008
    M T W T F S S
    « May   Jul »
  • Archives

Perl in Windows

Perl is a free and mature scripting language, created by Larry Wall. It is used as glue language for some of the hugin and libpano functionalities. Phil Harvey’s Exiftool, required by hugin, is also written in Perl.

Perl lends itself well for cross-platform scripting because it comes installed by default with most operating systems. Not with Windows. To work around Window’s limitation Steffen Müller maintains pp, a tool originally developed by Audrey Tang that creates standalone executables from Perl programs.

If you are just a Windows user, you can simply be thankful to Steffen and the PAR::Packer community for enabling developers and builders to supply you with a simple solution to run the software on your Windows box.

And if you are interested to know how to build those executables, read on this tutorial which I’ve put together with help from the PAR::Packer community, particularly Mark Dootson.

Infrastructure to build Windows executable from Perl scripts

This is highly experimental. it has been tested on PAR::Packer 0.980 released May 14, 2008.

Install MinGW – MSVC 2008 EE is not supported

  • Download MinGW-5.1.4.exe from the MinGW homepage.
  • Follow the default install (click all the “Yes” and “Next” buttons), but add g++ to the mix, i.e. on the screen where you can tick boxes to choose what to install, check the box with g++ (and leave anything else as is). It will be installed in C:\MinGW
  • Run the now installed C:\MinGW\MinGW-5.1.4.exe from the command line to ensure you get the latest updates.

Install ActiveState Perl 5.10.0 build 1002 (The free version is enough. Other/newer versions may also work, this is the one that worked for me).

Then start the Perl Package Manager (PPM) from the new entry in the Windows Start menu and search and install the following packages:

  • Get-opt-ArgvFile (>=1.07)
  • module-scandeps (>=0.78)
  • par-dist (>=0.22)
  • parse-binary (>=0.10)

Download dmake-4.11
Extract dmake to C:\MinGW so that you have a folder called C:\MinGW\dmake

Make yourself an environment batch file, call it perl.bat, with the following content. Use it to start the command line interface (CLI) with a double click.

set PERL_PATH=C:\Perl
set PATH=%MINGW_PATH%\bin;%MINGW_PATH%\mingw32\bin;%MINGW_PATH%\dmake;
set LIB=%MINGW_PATH%\lib;
set INCLUDE=%MINGW_PATH%\include;
set PATH=%PERL_PATH%\site\bin;%PERL_PATH%\bin;%PATH%
cmd /K

Install manually Win32-exe-0.11, Par-0.977 and Par-Packer-0.980.

  • Download the archives and extract them to temporary folders
  • doubleclick on perl.bat to start a CLI
  • in the CLI, run the following commandsinside each of the temporary folders
    > perl Makefile.PL
    > dmake
    > dmake test
    > dmake install

test your installation

create a file test.pl with the following content:

print "hello world!\n";

in the CLI, check that it works

> perl test.pl

compile it

> pp -o test.exe test.pl

test it

> test.exe

here you go, ready to build your perl scripts into Windows executables!

2 Responses

  1. Hi Yuval,

    just a slight correction and a suggestion:
    I didn’t write pp (or PAR::Packer). Both were originally developed by Audrey Tang in 2002-2003. I’ve just been the primary maintainer since 2005. edit: thanks, corrected.

    My suggestion is to try “Strawberry Perl” instead of ActiveState Perl. There’s nothing wrong with AS Perl, but for licensing reasons, they can’t bundle MinGW (and dmake) which Strawberry ships by default. So your instructions essentially boil down to:

    – install Strawberry Perl
    – run the cpan shell and install PAR::Packer (should work out of the box)
    – run pp

    Best regards,

  2. I was getting an error when I tried to install Par-Packer-0.9xx , the problem was that the paths that Makefile had were all like C:/path/file.exe and not like c:\path\file.exe as it was suppose to be, so I only had to do a full replace in all the Makefile’s (actually there are only 2) ‘et voilà’ done.

    hope this can help some problems.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s