Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

pp with gui

by mkmal (Novice)
on Mar 13, 2013 at 22:18 UTC ( #1023309=perlquestion: print w/replies, xml ) Need Help??

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

I recently downloaded PAR::Packer on Windows 7 to create .exe's from perl code. It works fine with command line perl but when I attempt to use it with gui code it does nothing. The command does not return and error, it just does not bring up the gui box like it does when I run it straight from perl.

Here is a small test case I am using.

use strict; use warnings; use File::Spec::Functions; BEGIN { if (exists $ENV{PAR_PROGNAME}) { use Config (); $ENV{PERL_TCL_DL_PATH} = catfile( $ENV{PAR_TEMP}, 'tkkit.' . $Config::Config{dlext}, ); } } use Tkx; Tkx::button(".b", -text => "Hello, world", -command => sub { Tkx::destroy("."); }, ); Tkx::pack(".b"); Tkx::MainLoop()
If I run a text box pops up with a "Hello World" button.
If I run gui1.exe the command completes with no errors but no box pops up.

The command I use to successfully create the .exe is
pp --gui -o gui1.exe

Did I enter the command incorrectly or is there another problem?

Replies are listed 'Best First'.
Re: pp with gui
by marto (Cardinal) on Mar 13, 2013 at 22:30 UTC

    Use the -x flag (note, lowercase) when calling pp. See Problem with getSaveFile in 'pp'-mode. Consider also using the verbose flag when calling pp and actually unpacking your executable (you can simply unzip it) to ensure all prerequisites are packaged.

      I entered the pp command with the -x option.

      pp -x --gui -o gui1.exe

      It gets to this point and brings up the text box.

      pp: Packing

      It hangs until I click on the text box and then the compile completes.

      The resulting .exe still does nothing.

      --verbose gives me a lot of output but no errors.

      Any ideas?
Re: pp with gui
by Anonymous Monk on Mar 13, 2013 at 23:43 UTC
      I tried adding -l, same result.

        I tried adding -l, same result

        sure sure, in any case, try the other tips i linked, turn on debugging ...

Re: pp with gui
by Anonymous Monk on Mar 28, 2013 at 03:59 UTC
       pp -e " use Data::Dump; dd\@ARGV; dd\@INC; dd\%INC; dd\%ENV; use PAR; dd[split/[\r\n]+/,PAR::read_file(q{MANIFEST})]; "
        #!/usr/bin/perl -- use strict; use warnings; use Data::Dump; use PAR; dd { 'PAR_MANIFEST' => [split/[\r\n]+/,PAR::read_file(q{MANIFEST})], '%INC' => \%INC, '%ENV' => \%ENV, '@INC' => \@INC, '@ARGV' => \@ARGV, };
Re: pp with gui
by Anonymous Monk on Mar 25, 2013 at 01:35 UTC
    Add $Tkx::TRACE=64; or some print statements or turn on PAR debugging
      I added the line


      to my code and compiled as shown above. Everything behaves exactly the same.
        Impossible. OTOH, turn on par debugging.

        Are you still using pp --gui ?

        You should probably omit the --gui option until you've got your program working as it should under par

Re: pp with gui
by golux (Chaplain) on Apr 04, 2013 at 16:33 UTC
    Hi mkmal,

    I've been in the habit of using ASP's perlapp, but it unfortunately requires a paid license that not everyone wants to spend money for. (I'm lucky that I need it for work, and my company generously paid for the license).

    So this seemed a good chance to learn an alternative approach.

    I tried many of the same steps that you did, and got mostly the same results. Then I noticed you had modified your pp command to:

    pp --gui -o gui2.exe -l C:/Perl/lib/auto/Tcl/tkki. dll -l +C:/Perl/lib/auto/Tcl/Tcl.dll
    and I realized there was a typo in "tkki. dll" -- beside the extra space, it should be "tkkit.dll".

    Once I changed that:

    pp --gui -o gui1.exe -l C:/Perl/lib/auto/Tcl/tkkit.dll -l +C:/Perl/lib/auto/Tcl/Tcl.dll

    the executable "gui1.exe" works as it should have.

    You later said:

    Here is the command I am using now. Please let me know if you see +any more errors. pp --gui -o gui1.exe -l C:/Perl/lib/auto/Tcl/tkkit.dll -l +C:/Perl/lib/auto/Tcl/Tcl.dll -x

    I tried that as well, both with and without the -x; both worked ("gui1.exe" ran as expected). The only difference seemed to be that -x caused the gui to appear during compilation. Is it possible you *thought* you've corrected the "tkkit.dll" typo, but still have it (maybe in your "build" script?)

    A few notes -- the app does startup kind of slowly, though (at least compared to apps I've built with "perlapp"). But when I run it a few more times, it seems to start quicker after the initial run.

    It was fairly difficult to installing PAR::Packer (this was on a Windows 7 machine), at least for my ActiveState Perl environment. The thing that finally worked for me was:

    C:\> ppm install MinGW C:\> cpanp i PAR::Packer

    Update: added the prerequisite "ppm install MinGW"

    Update 2: After installing on a different Windows 7 machine, I see that the tests fail for "ppm install MinGW":

    Result: FAIL dmake: Error code 129, while making 'test_dynamic' dmake: Error code 255, while making 'subdirs-test'
    It didn't seem to matter; answering 'y' to:
    The tests for 'Win32::Exe' failed. Would you like me to proceed anyway or should we abort? Proceed anyway? [y/N]: y

    was ultimately successful at installing "PAR::Packer" and "pp".

    say  substr+lc crypt(qw $i3 SI$),4,5


      "The only difference seemed to be that -x caused the gui to appear during compilation."

      -x actually runs the script to determine additional runtime dependancies. So if a GUI is in use then it'll be displayed.

      "Is it possible you *thought* you've corrected the "tkkit.dll" typo, but still have it (maybe in your "build" script?)"

      Possible, but it's hard to say given they copy and paste different things at different times and refuse to acknowledge the runtime warnings. You'll notice they provide different messed up pp calls at multiple times in the thread. Note that use of -gui isn't recomended if there are problems when running the executable created. It obscures the problem, as can be seen from several posts in this thread.

      "But when I run it a few more times, it seems to start quicker after the initial run."

      The first run will extract the whole zip file to a temporary area (for example C:\Documents and Settings\user\Local Settings\Temp\par-user), subsequent runs are quicker as they use this cache.

      Note that ActiveState currently don't provide a 64bit package for MinGW, so you need to install it yourself.

      Hey golux, you are awesome!!

      I was going through your post and at first I thought you made a typo when you said you ran 'cpanp i PAR::Packer'
      I thought you just accidently added a 'p' to cpan but a quick google introduced me to cpan plus.

      Figuring they may have a better version I uninstalled PAR::Packer using ppm.
      I attempted to run 'ppm install MinGW' but it said it was already installed (no missing packages). I then copied and pasted your 'cpanp' command.
      I didn't see any errors.
      Next, I ran the same pp command I had been running and gui1.exe was created without error which is what I had been seeing all along.

      I ran the .exe and for the first time it worked! A little slow the first time like you said.

      And to think I was just about ready to drop this issue for a while. Thanks again!
        Glad to hear it!

        Marto is right about the -x switch; I hadn't yet read that far in the pp docs, but now I see why "pp" would want to run the program first, to further evaluate what other modules (eg. DLLs) are needed.

        He's also correct about the cached files, it seems that using the -C (or --clean) switch to "pp" will:

        Clean up temporary files extracted from the application at runtime. By + default, these files are cached in the temporary directory; this all +ows the program to start up faster next time.

        I'm excited that this new way (for me) of packaging Perl programs seems an elegant (and cheap) alternative to ASP's "perlapp". I tried using it with Tk and it worked very smoothly.

        Here's my demo program; you can call it with --exe to build the executable:

        ## # PAR::Packer example using Tk # # Notes: # # 1. Run this script, and it creates a simple Tk App # 2. Install PAR::Packer in Windows using: # # C:\> ppm install MinGW # C:\> cpanp i PAR::Packer # # Don't worry if Win32::Exe tests fail: # # dmake.exe: Error code 129, while making 'test_dynamic' # dmake.exe: Error code @55, while making 'sudirs-test' # # Just select 'y' when prompted: Proceed anyway? [y/N]: y # # 3. To make the executable, type "<script> --exe" # # ############### ## Libraries ## ############### use strict; use warnings; use File::Basename; use Tk; ################## ## Main program ## ################## my $src = basename $0; (my $exe = $src) =~ s/[.]pl$/.exe/; if (@ARGV > 0 and $ARGV[0] eq '--exe') { my $cmd = "pp --gui -o $exe $src"; print "Command: $cmd\n"; system($cmd); exit; } # Tk Gui my $mw = new MainWindow(-title => 'PAR::Packer with Tk Example'); my $frm = $mw->Frame->pack(-expand => 1, -fill => 'both'); my $b1 = $frm->Button(-bg => '#ffefb3', -text => 'Hello World'); my $b2 = $frm->Button(-bg => '#ffefb3', -text => 'Quit (^Q)'); $b1->configure(-command => sub { print "Hello world!\n" }); $b2->configure(-command => sub { exit }); $b1->pack(-side => 'left'); $b2->pack(-side => 'right'); $mw->bind("<Control-q>" => sub { $b2->invoke }); $mw->MainLoop;
        say  substr+lc crypt(qw $i3 SI$),4,5
      Wow, thanks. This is very helpful and I am going to check everything out. I'm glad I decided to look for posts one more time.

      >>Is it possible you *thought* you've corrected the
      >>"tkkit.dll" typo, but still have it (maybe in your
      >> "build" script?)

      I actually cut and pasted the exact command line I entered into my Console window (I'm not using a build script).

      Thanks again for posting this and I will report back my progress.

        "I am going to check everything out."

        I live in hope, but we've been round this loop several times before.

        "I actually cut and pasted the exact command line I entered into my Console window (I'm not using a build script)."

        It's inconsistent at various points throught your thread, either you didn't copy and paste it or you've made multiple mistakes when typing it several times. Consider testing paths actually exist, tab them out in the same way you do under linux/unix.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2023-06-09 12:21 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (35 votes). Check out past polls.