1PAR::FAQ(3)           User Contributed Perl Documentation          PAR::FAQ(3)
2
3
4

NAME

6       PAR::FAQ - Frequently Asked Questions about PAR
7

SYNOPSIS

9       This is the Frequently Asked Questions list for the Perl Archive
10       Toolkit.  You can edit this document at <http://par.perl.org/wiki/FAQ>
11       online.  This (included) FAQ list might be outdated. The Wiki version
12       at the above URL is guaranteed to be up to date.
13

DESCRIPTION

15   Where is the Windows binary version?
16       You can find windows binaries here:
17
18       <http://www.cpan.org/authors/id/S/SM/SMUELLER/>
19
20       There are three ways to install them. Sorted in order of preference:
21
22       cpan
23
24       Run the cpan command line tool that comes with Perl. In the cpan shell,
25       type
26
27         install PAR
28
29       and wait for the script to download and extract PAR and its
30       dependencies. If you have a C compiler installed, PAR will be built on
31       your computer for your specific version of Perl. If you do not have a C
32       compiler, the installer will look at the site referenced above for a
33       compatible binary release and ask you whether you would like to install
34       it.
35
36       ppm
37
38       If you are using ActivePerl from ActiveState, you can use the 'ppm'
39       program that comes with the ActiveState Perl. Instructions can be found
40       below. PAR is availlable from various PPM repositories and some
41       packages are compatible with some versions of ActivePerl and not with
42       others. There is an incomplete PAR-Win32 Binary Compatibility List at
43       <http://par.wikia.com/wiki/PAR_PPM_Compatibility_List> There are at
44       least three relevant PPM repositories: The default ActiveState one, the
45       bribes repository which is used in the example below and Randy Kobes'
46       repository at <http://theoryx5.uwinnipeg.ca/ppms/>.
47
48           C:\> ppm3
49           # activestate was out of date compared to this one
50           % rep add bribes http://www.bribes.org/perl/ppm
51           # move it to first place on list of repositories
52           % rep up bribes
53           CPAN>upgrade -install PAR
54
55       And finally, 'q' to quit and that's all :-) You have access to pp and
56       so on...
57
58       manual
59
60       For reference, here's the old explanation of how to install it by hand:
61       The file you need will be called
62       PAR-X.XX-MSWin32-x86-multi-thread-Y.Y.Y.par where X.XX is the version
63       of PAR you will use and Y.Y.Y is the version of Perl you have. Unzip
64       this file (you may need to rename it to end with .zip instead of .par
65       first) and copy all the files in the script directory into a directory
66       in your PATH. Now you should be able to use PAR.
67
68   Can PAR bundle all its prerequisites?
69       Note: This entry needs serious attention.
70
71       Yes and no.
72
73       It would be possible to do this but it would also introduce a
74       maintenance nightmare. A new version of PAR would have to be released
75       whenever a new version of any of the dependencies came out. This is
76       already painful with the included Module::Install.
77
78       The original proposal which led to this FAQ entry considered the case
79       where you want to install PAR without a working CPAN.pm/CPAN shell
80       installation or without internet connectivity. By default, PAR will try
81       to install its dependencies from CPAN using the CPAN.pm module.
82
83       Given that you have a development machine with PAR installed and with a
84       working CPAN.pm, it is reasonably simple to create one or more .par
85       distributions of PAR's dependencies. Install PAR::Dist::FromCPAN. Then
86       you can create .par distributions (read: binaries installable with the
87       pure-perl PAR::Dist on the same architecture) for the PAR dependencies
88       as follows:
89
90         mkdir par_files
91         cpan2par --pattern PAR --follow --out par_files/ --merge --skip File::.*
92                  --skip Getopt::Std --skip Carp --skip Data::Dumper --skip Time::Local
93                  --skip 'Test\b.*' --skip Text::ParseWords --skip ExtUtils::.*
94                  --skip Getopt::Long --skip Text::Abbrev --skip DirHandle --skip Pod::.*
95
96       (Line breaks inserted for readability.) What happens here? cpan2par
97       uses the API of the CPAN.pm module to fetch the PAR distribution from
98       CPAN, unpacks it, builds it, creates a .par archive from its compiled
99       state and then does the same for any of its dependencies. And then for
100       its dependencies dependencies and... You get the idea. This is what the
101       --follow option does. We add a couple of --skip options to skip core
102       modules which we need not include and any Test::* modules. The --merge
103       option merges all of the .par distributions into the original PAR one.
104       Voila! (Future versions of PAR::Dist::FromCPAN might include an option
105       --skip-core which would skip any modules contained in the core
106       distribution.)
107
108       After this command worked its magic, you should have a single file
109       PAR-VERSION-ARCHNAME-PERLVERSION.par in the subdirectory 'par_files/'.
110       You can now install PAR and its non-core dependencies on any machine
111       that has the architecture of your development system (and a binary
112       compatible perl version) using PAR::Dist as follows:
113
114         perl -MPAR::Dist -einstall_par
115
116       Provided that you run the command from within the directory containing
117       the aforementioned .par file (and no other .par file).
118
119       Since you might not even have PAR::Dist on the target machine, you can
120       do this simple hack to get a basic installer:
121
122         perl -MPAR::Dist -e'open my $fh, "<", $INC{"PAR/Dist.pm"}; print <$fh>;
123              print "\npackage main;\nPAR::Dist::install_par(\@ARGV ? shift(\@ARGV)
124              : ());\n\n"'
125              > installer.pl
126
127       (Again: Line breaks inserted for readability.) This looks for your
128       installed copy of PAR::Dist, reads it, writes it to STDOUT and appends
129       two lines of code: "package main;" and a call to
130       PAR::Dist::install_par. By default, it will install any (single) .par
131       file in the current directory. If supplied with a file name as first
132       argument, it will install the specified file. It should have no non-
133       core dependencies! So shipping the generated PAR-....par file and the
134       installer.pl file to the target machine and running "perl installer.pl"
135       should just magically install PAR and its dependencies for you.
136
137       Now, this whole trick works equally well for any other modules. In
138       fact, if you have PAR on the target machine, you needn't even install
139       the modules in the .par file in order to use them! You can just add
140       "use PAR 'foo-bar.par';" to your code and any modules will be loaded
141       from the .par file as necessary. ("perl -MPAR=foo-bar.par
142       your_script.pl" works, too.) The documentation of the PAR module has
143       details on this.
144
145       Finally, note that you can install PAR::Repository::Client on the
146       target machines and subsequently use PAR 0.951 and later to
147       automatically fetch any unfulfilled dependencies from a (remote or
148       local) repository:
149
150         use PAR { repository => 'http://my_local_secure_host/repository' };
151
152       or:
153
154         use PAR { repository => 'file:///path/to/repository' };
155
156       Details, again, in the PAR documentation and in the
157       PAR::Repository::Client documentation.
158
159       Answer from: Steffen Mueller, 16 August 2006
160
161   If I try to compile my wxGlade generated script, it doesn't run. What's
162       wrong?
163       Note: Is this still a problem?
164
165       Comment out the line that starts with " unless (caller) ", and compile
166       it again. Note that this is considered a bug; clearing the caller stack
167       is a development in progress. See:
168       <http://par.perl.org/wiki/Development_in_progress>
169
170   I get a link error '/usr/bin/ld: cannot find -lperl' during the 'make' step
171       of the installation on Debian. What's wrong?
172       This is a common problem when building compiled libraries on Debian
173       distribution installations with the default perl package. To fix this
174       problem, create a symbolic link from libperl.so.5.6.1 to libperl.so in
175       /usr/lib (cd /usr/lib; ln -s libperl.so.5.6.1 libperl.so) and re-run
176       the 'make' step of the installation. Or install libperl-dev
177
178   I specify a .ico file with --icon for Win32, but the icon is still the
179       black and white camel. What's wrong?
180       Unlike Perl2EXE, which can use a standard 16-color bitmap as an
181       application icon, PAR requires a true Windows icon file. Download a
182       trial version of Microangelo and use that to create your .ico file. The
183       latest Netpbm tools at <http://netpbm.sourceforge.net/> has
184       ppmtowinicon, which can tack a pbm and convert it to a windows icon. It
185       is open source and has win32 ports.
186
187       Gimp for Windows can also create Windows icon files
188       http://gimp-win.sourceforge.net/ <http://gimp-win.sourceforge.net/>.
189
190   I added a directory to my PAR file using "zip -r" or winzip, and then
191       generated an executable from this PAR file, and the executable failed
192       to run (IO error: reading header signature :..). What's wrong?
193       As pointed out by Alan Stewart, zip adds a directory entry for the new
194       directory, and it causes the PAR executable to fail. Just use :
195
196         zip -r -D hello.par my_dir/
197
198       or the Archive::Zip::addTree as follows :
199
200         $zip->addTree( $root, $dest, sub { -f } )
201
202   On what platforms can I run PAR? On what platforms will the resulting
203       executable run?
204       Win32 (95/98/ME/NT4/2K/XP), FreeBSD, Linux, AIX, Solaris, Darwin and
205       Cygwin.
206
207       The resulting executable will run on any platforms that supports the
208       binary format of the generating platform.
209
210   How do I extract my script out of packed executable?
211       In other words, "I did a `pp foo.pl' and I lost foo.pl, how do I get it
212       back?".
213
214       The answer is to just use unzip/winzip/winrar/whatever to decompress
215       the executable, treating it like a normal Zip file. You may need to
216       rename the executable into a .zip extension first.
217
218   Can PAR completely hide my source code?
219       Not completely, but possible to a degree. Starting from version 0.76,
220       PAR supports an input filter mechanism, which can be used to implement
221       source obfuscators (or even product activation schemes).
222
223       But if you are looking for 100% bulletproof way of hiding source code,
224       it is not possible with any language. Learning Perl, 3rd Edition has
225       this answer to offer (quoted with permission from Randal Schwartz):
226
227       If you're wishing for an opaque binary, though, we have to tell you
228       that they don't exist. If someone can install and run your program,
229       they can turn it back into source code. Granted, this won't necessarily
230       be the same source that you started with, but it will be some kind of
231       source code. The real way to keep your secret algorithm a secret is,
232       alas, to apply the proper number of attorneys; they can write a license
233       that says "you can do this with the code, but you can't do that. And if
234       you break our rules, we've got the proper number of attorneys to ensure
235       that you'll regret it."
236
237       Other than that, I would point you at PAR::Filter::Crypto. Be sure to
238       read the CAVEATS and WARNINGS sections of the documentation.
239
240   On Windows XP, pp crashes saying that "par.exe has encountered a problem"
241       This is believed to be fixed by PAR 0.76_99. The following answer
242       applies to PAR 0.76 and earlier:
243
244       You may be able to escape this problem by setting some executables to
245       Windows 95 compatibility mode. Specifically, find "parl.exe" (probably
246       in "C:\perl\5.8.0\bin") using Windows Explorer, and right-click on it
247       and choose "Properties". Choose the "Compatibility" tab and tick the
248       box for "Run this program with compatibility mode for" and check that
249       the dropdown shows "Windows 95". Then click OK.
250
251       Now you can hopefully run pp as normal to generate an EXE. Before you
252       can run the generated EXE, you'll need to set its compatibility mode
253       too, in the same way as you did for parl.exe.
254
255       This workaround is known not to work in all cases, and the developers
256       are working on a solution to the problem. See these posts for more
257       info:
258
259       http://www.mail-archive.com/par@perl.org/msg00423.html
260       <http://www.mail-archive.com/par@perl.org/msg00423.html>,
261       http://www.mail-archive.com/par@perl.org/msg00435.html
262       <http://www.mail-archive.com/par@perl.org/msg00435.html>,
263       http://www.mail-archive.com/par@perl.org/msg00573.html
264       <http://www.mail-archive.com/par@perl.org/msg00573.html>,
265       http://www.mail-archive.com/par@perl.org/msg00670.html
266       <http://www.mail-archive.com/par@perl.org/msg00670.html>
267
268   Perl Tk tips
269       On Windows XP start your script with
270
271         use strict; use Encode::Unicode; use Tk;
272
273       Some widgets use xbm bitmaps which don't get picked up by PAR. The
274       error is:
275
276         couldn't read bitmap file "": No such file or directory
277         error reading bitmap file "" at Tk/Widget.pm line 205.
278         at Tk/Widget.pm line 203
279
280       Fix is to find the missing xbm files (perl -V tells you where to start
281       looking) and add them to the executable eg
282
283       copy missing xbm files to script directory then:
284
285           % pp --add cbxarrow.xbm --add arrowdownwin.xbm -o test test.pl
286
287   Problem with Win32::Perms and Perms.DLL
288       With a script my.pl using Win32::Perms, pp -o my.exe my.pl you may
289       have:
290
291         Can't locate loadable object for module Win32::Perms in @INC
292         (@INC contains: CODE(0xb97eec) CODE(0xc8a99c) .)
293         at ../blib/lib/PAR/Heavy.pm line 78
294
295       In fact the dll is Perms.DLL wit DLL in capital letters. That's the
296       problem. The bootstrap function of PAR in the Dynaloader module fails
297       looking for Perms.dll in the table of dlls which contains only
298       Perms.DLL. And so the solution is just rename Perms.DLL in Perms.dll
299       and do pp -o my.exe my.pl ... and everything goes right.
300
301   Under Win32, a pp packed executable has trouble executing other perl
302       scripts or pp packed executable
303       Note: Is this still current?
304
305       When running on a Win32 system, if a perl script is packed with pp and
306       invokes another Perl script or pp packed executable, either with
307       system() or backticks, the invoked program runs with the copy of
308       perl5x.dll already loaded into memory. If the calling executable was
309       packed with "pp -d", the perl5x.dll is the one from the installed perl
310       bin directory. Otherwise, it is the one packed with the executable. The
311       perl5x.dll from the bin dir knows the @INC paths for the installed
312       libraries; the one in the executable does not. Because of this, a
313       program packed without "-d" calling a program with packed with "-d" or
314       calling perl.exe to run a plain Perl script may fail. This is a Win32
315       limitation.
316
317   How can I make a .exe that runs with no console window under Windows?
318       Use the --gui switch, ie
319
320           % pp --gui -o file.exe file.pl
321
322       I found that this is not documented on all versions of pp ... Some
323       versions have a more complete doc than others when you type "pp -h"
324       etc. (This should be reasonably documented now.)
325
326       When searching for an answer to this myself, I found many references to
327       using "exetype" ... it comes as a .bat with ActivePerl, or you can find
328       an exetype.pl from several places. You run "exetype file.exe
329       [WINDOWS|CONSOLE]". This worked, I think, but still did not achieve the
330       desired result on my PAR executable. While the exe itself did not
331       generate a console window, par.exe (which was invoked in my exe
332       somewhere) DID generate a console window, with a titlebar saying
333       "par.exe <strange-looking path to file in temp dir>", whereas before
334       changing the console window title bar just displayed the path to my
335       .exe.
336
337   How can I change the icon of the generated .exe file under Windows?
338       There is another not-completely-documented switch that only works on
339       windows, aXXicon MyIcon.ico. So just use this:
340
341           % pp --icon "c:\path to\MyIcon.ico" -o file.exe file.pl.
342
343       (This should also be documented now?)
344
345   The command line parameters (@ARGV) of a pp-ed binary called from another
346       pp-ed binary are missing or broken. What the...?
347       This was a bug in releases up to and incuding PAR-0.90. Please upgrade
348       to PAR 0.91 or later and the problem will go away.
349
350   I want to include a pp-ed binary in an RPM package. How can I make this
351       work?
352       The binary executables outputted by pp (on Linux) are not valid ELF
353       binaries because it basically attaches a zip archive to the binary
354       loader and does not modify the ELF headers to reflect that. When
355       building an RPM archive, the validity of the ELF headers is checked by
356       default. This can result in problems when packaging pp-ed binaries in
357       RPM archives.
358
359       Scott McBrien helped track down what can be done to get this to work:
360
361         [I]t appears that the RPM archive that is generated gets a list of
362         the MD5 sums for components of the executable file calculated by
363         prelink.  By disabling prelink, it fixed the problem; in my RPM .spec
364         file:
365         %define         __prelink_undo_cmd     %{nil}
366
367       After quite some time, it seems like the smart folks at Redhat found
368       the culprit. I'm glad *they* did, because I wouldn't have:
369
370         It appears that we found a solution that works. It like the pp
371         executables are already stripped, so we don't want rpm stripping them
372         again, which, of course, renders them useless.
373
374         In this case, we added the following lines to the spec file to keep rpm
375         from running the strip process and not produce debuginfo packages:
376
377         %define __spec_install_post :
378         %define debug_package %{nil}
379
380         Don't forget to add the ":" character to __spec_install_post as above or
381         this won't work.
382
383       Much praise to all who helped track this down! The discussion can be
384       found in the following RT tickets:
385       "/rt.cpan.org/Public/Bug/Display.html?id=18536 #18536" in http: and
386       "/rt.cpan.org/Public/Bug/Display.html?id=19609 #19609" in http:.
387
388       -- Steffen Mueller, 22 July 2006
389
390   How can I package Wx applications?
391       Have a look at the separately maintained Wx::Perl::Packager module.
392
393       -- Steffen Mueller, 3 July 2006
394
395   How can I package Catalyst web applications?
396       Catalyst has some builtin PAR support. I found the following URL to be
397       very helpful:
398
399       <http://catalyst.infogami.com/cookbook/par>.
400
401       -- Steffen Mueller, 21 July 2006
402
403   The resulting files are huge! How can I reduce the size of the output file?
404       The executables generated by pp generally contain a copy of your Perl
405       shared libraries, the Perl core modules and any module dependencies
406       your packaged application may have. That is a lot. Sometimes, PAR
407       packages too much. It adheres to the philosophy of rather making the
408       application work than generating a streamlined executable. If you want
409       to optimize this, you will have to do so by excluding specific modules.
410
411       Chris Dolan's recent post to the PAR mailing list explains this well.
412       Quoting Chris: (<http://www.nntp.perl.org/group/perl.par/2490>)
413
414         [...]
415         I've found a few tricks that can help a lot:
416
417         * If you know the target platform has Perl pre-installed (e.g. Mac OS X)
418           then use the "--dependent" flag. This skips all of the core modules,
419           yielding a much smaller executable.
420
421           One significant caveat is moving to older systems.  For example,
422           Mac OS X 10.2 had Perl 5.6.0 which has 146 fewer core modules than
423           Perl 5.8.6 which shipped with Mac OS X 10.4, and (even more significantly)
424           is binary-incompatible with any extra XS modules added from CPAN.
425           Other platforms can be even harder to predict.
426
427         * Watch for modules that pull in lots of dependencies
428
429           A good example is DBI.  If your program uses DBI, then Module::ScanDeps
430           pulls in ALL of the DBD::* modules (some of which are large) installed on
431           your system, because it cannot realistically parse the DBI->connect()
432           arguments which specify which database drivers are actually needed.
433           In one of my MySQL-based applications, I use this invocation of PAR:
434
435             pp -X DBD::SQLite -X DBD::CSV -X DBD::File -X DBD::Excel
436
437           which saves quite a few bytes, because both DBD::SQLite and DBD::Excel
438           have lots of CPAN dependencies.  The actual list if DBD::* modules you
439           need to exclude depends on your system.  Here's a short command that will
440           reveal all DBD::* modules on a unix-like system:
441
442             perl -MModule::ScanDeps -le'print for map {"DBD/".$_->{name}} Module::ScanDeps::_glob_in_inc("DBD")'
443
444           Another smaller example is SOAP::Transport::* where most installations
445           only need SOAP::Transport::HTTP.
446           [...]
447
448       Similar techniques can be applied when a module makes use of
449       Module::Pluggable for plugins.
450
451       Finally, there is a PAR filter available as a separate distribution on
452       CPAN which compresses the source code as much as possible by first
453       parsing it using PPI and then spitting out a reduced functional
454       equivalent: PAR::Filter::Squish.
455
456       -- Steffen Mueller, August 2006
457
458   How do I use Win32::GUI::SplashScreen with PAR?
459       When using pp to package an application that uses
460       Win32::GUI::SplashScreen, try adding the splashscreen bitmap manually
461       as suggested in the Win32::GUI::SplashScreen docs:
462
463         pp -a SPLASHFILE.bmp -o xxx.exe xxx.pl
464
465   The Perl Packager scripts says that it can create executable that runs in
466       same OS. Can I use it to create Win32 binary with linux machine? Or
467       what should I use to create Win32 executable binary on linux from my
468       script?
469       It is not possible to create stand-alone binaries for different
470       platform than what you are currently running on. This is a generally
471       hard problem since you would have to cross-compile all XS modules and
472       perl itself. Not nice.
473
474       For example, if you would like to develop an application on Linux and
475       ship it for both Linux/x86 and Win32/x86, it works well to set up a
476       Virtual Machine with a Windows (XP or 2000 or whatever) and a Perl
477       installation. On that machine, use PAR/pp to package your application
478       for Win32.
479
480       See also the question "On what platforms can I run PAR? On what
481       platforms will the resulting executable run?".
482
483       -- Steffen Mueller, 2 November 2006
484

SEE ALSO

486       PAR, PAR::Tutorial
487

AUTHORS

489       Audrey Tang <cpan@audreyt.org>, Steffen Mueller <smueller@cpan.org>
490
491       <http://par.perl.org/> is the official PAR website.  You can write to
492       the mailing list at <par@perl.org>, or send an empty mail to
493       <par-subscribe@perl.org> to participate in the discussion.
494
495       Please submit bug reports to <bug-par@rt.cpan.org>.
496
498       Copyright 2003-2008 by Audrey Tang <cpan@audreyt.org>.
499
500       This document is free documentation; you can redistribute it and/or
501       modify it under the same terms as Perl itself.
502
503       See <http://www.perl.com/perl/misc/Artistic.html>
504
505
506
507perl v5.12.1                      2010-04-10                       PAR::FAQ(3)
Impressum