سؤال

I know it's ugly, but i need to compile a perl script on windows for a client, so basically i am trying to make an .exe out of my .pl script.

I am using PAR::Packer installed via cpan, and i compiled a bunch of simple script before sucessfully.

It worked ok before but it looks not working now since i added use Text::CSV;

It works, but when i run the .exe it gives this error:

Can't locate Text/CSV_PP.pm in @INC (@INC contains: CODE(0x25f1f84) C:\Users\user
\AppData\Local\Temp\par-6b6f6e74757a\cache-6d4baa68e36871e6407210ca47953c635f
81e612\inc\lib C:\Users\user\AppData\Local\Temp\par-6b6f6e74757a\cache-6d4baa6
8e36871e6407210ca47953c635f81e612\inc CODE(0x239f2ec) CODE(0x239f67c)) at (eval
18) line 2.
 at script/csvutil.pl line 5.
Compilation failed in require at script/csvutil.pl line 5.
BEGIN failed--compilation aborted at script/csvutil.pl line 5.

Basically what i do is:

pp -o csvutil.exe csvutil.pl

I tried adding forcing loading modules by :

pp -M Text::CSV csvutil.pl

I think i am missing something...

I am working with strawberry perl 5.16

The beginning of code:

#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use Text::CSV;

my $file = $ARGV[0];
my @rows;
my $csv = Text::CSV->new ( { binary => 1 ,sep_char => ",",allow_loose_quotes => 1, eol=> $/, always_quote =>1 } )  # should set binary attribute.
             or die "Cannot use CSV: ".Text::CSV->error_diag ();

     ...# basically print all the lines
هل كانت مفيدة؟

المحلول

Text::CSV is really just an interface. It automatically determines which back end module to use: either the pure-Perl Text::CSV_PP or the XS (C code) Text::CSV_XS. PAR is detecting the static dependency on Text::CSV but can't resolve the dynamic dependency. Change your -M option to include either Text::CSV_XS or Text::CSV_PP. Bundle the XS version if you have it installed. It's much faster.

نصائح أخرى

There might be problem with the path in @INC. Probably you may find your answer here

I would suggest moving away from PAR and using Cava Packager. I've used PAR in the past and it was hit or miss whether or not I would ever get the application packaged. It doesn't seem to handle certain modules very well, and when you come across one it can't handle the resources are sparse and the fixes are usually dirty hacks. Gtk+/Tk apps really give PAR a hard time.

Cava Packager on the other hand is very robust, actively maintained and has been able to handle all the modules I throw at it. It allows you/the community to create rules about how to handle special cases for specific modules. Any issues I have come across have been quickly resolved via the active mailing list. It provides a GUI to configure the project settings. It has InnoSetup support to create an installer automatically when packaging your app. It is actively maintained and is currently working to become open-source. Until I found Cava Packager I had pretty much given up on the idea of packaging perl scripts as an executable for distribution. Cava went above-an-beyond the expectations I had set after using PAR and ActiveState's perl2exe. It might sound like I am a developer for Cava, but I'm really not! Just VERY HAPPY with it.

I know this doesn't exactly answer the question you posed, but it does address your problem and I thought you might find Cava as useful as I have.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top