1

I'm having a lot of trouble with compiling my perl script. I'm using all sorts of modules in my script:

use fetchinfo; #which I wrote so it's in the same directory as my script
use threads;
use threads::shared;
use Tk;
use Fcntl ':flock';

And fetchinfo.pm also uses this modules:

use WWW::Mechanize;
use URI::Escape;
use Date::Calc qw(Delta_Days);
use LWP::Simple;
use HTML::Parser;

I got ActivePerl installed on my machine (64-bit Win 7).

I'm trying to compile my code and make it an independent .exe file (although it would be great to be able to compile for other systems too (since I think my code doesn't use any system specific functions).

I don't mind installing a virtual machine (if 32-bit win is required or linux), I don't mind installing Strawberry perl instead of ActivePerl... I just want to be able to compile the code :-)

trying to use perl2EXE it said it can't find a few of the modules (although everyone of those were installed by ppm). I tried compiling on linux with Perl Packager (PAR::Packer) (Since it doesn't show on ppm and I had trouble installing it any other way) but the file which got created didn't work.

... help? :-)

Phil Miller
  • 36,389
  • 13
  • 67
  • 90
Thatkookooguy
  • 6,669
  • 1
  • 29
  • 54
  • Common practice is to use `lower_case` for *pragmatic* packages (such as `strict` and `warnings`) and `CamelCase` for *functional* packages. People familiar with Perl would thank you for calling your package `FetchInfo`. – Borodin Mar 23 '13 at 12:52
  • The actual package name isn't Fetchinfo. I just didn't want to write the real name of the package. The real name uses the convention you mentioned but thanks for the heads up – Thatkookooguy Mar 23 '13 at 13:29

1 Answers1

0

Are you aware that all perl2exe does is to create a copy of the perl interpreter executable that includes all your source files (possibly in a compiled state, I'm not sure)?

I recommend that you use the PAR package instead, which will build a single archive file containing all the necessary sources that can be run from the perl command line.

If you absolutely must have a single executable image, then look at PAR::Packer instead.


Update

I actually want this program to run on computers without perl installed on them. I understood I have to compile my code for this to work. PAR package doesn't do that, right?

No, you don't have to compile Perl source to put it into a package. It is counter-productive to do so as load times tend to increase due to the extra ByteLoader module necessary to interpret the resulting parse tree.

I actually need help installing and using PAR::Packer since I couldn't install it on ActivePerl on windows and the executable it made for me on linux didn't work on windows 64-bit. So I'm doing something wrong

I don't have an instance of ActivePerl, but Par::Packer installs fine on Strawberry Perl 5 version 16.2 and passes all tests. Please understand that you cannot build an executable on one system that will run on a different platform. This applies to every language, not just Perl. You need working version of Perl on a system compatible with your target to be able to build an executable that will work elsewhere.

Community
  • 1
  • 1
Borodin
  • 126,100
  • 9
  • 70
  • 144
  • I actually want this program to run on computers without perl installed on them. I understood I have to compile my code for this to work. PAR package doesn't do that, right? + I actually need help installing and using PAR::Packer since I couldn't install it on ActivePerl on windows and the executable it made for me on linux didn't work on windows 64-bit. So I'm doing something wrong. – Thatkookooguy Mar 23 '13 at 13:30
  • @Thatkookooguy: I have added to my answer to explain. – Borodin Mar 23 '13 at 14:13
  • I didnt mean one executable to run on every system. I meant a compiler (or packer) that can make on a single machine the executables for every OS. I know perl2exe have a flag with the os you want to pack the file for. so it makes a .exe if you select windows and it makes a linux executable with you select that you want to pack your code to run later on linux. and I'm not quite sure I got your right. you mean that the PAR will run even on a computer without perl on it because it packs an instance of perl on it? Also, did you try to install Par::Packer on strabery Perl 5 on windows 32 or 64 bit? – Thatkookooguy Mar 23 '13 at 21:12
  • I doubt if that's possible. I guess `perl2exe` does it by keeping a library of perl builds for all the platforms it supports, and choosing one of these to bundle with your sources to create a single executable image file for the required platform. And yes, that is exactly what I mean about `PAR::Packer`. The only way for anything to create an executable file from a Perl script is to bundle a working perl compiler/interpreter together with the script. I installed `PAR::Packer` on W7 x64. – Borodin Mar 23 '13 at 22:20
  • I have never used it myself, but you may get some mileage out of [`Cava Packager`](http://www.cavapackager.com/). I have also found this in the [Perl2Exe documentation](http://www.indigostar.com/pxman.html): *"If it dies with a "Can't locate somemodule.pm in @INC ... " error message, then add an explicit use statement for the missing module to your script."*, which may be of some use to you. – Borodin Mar 23 '13 at 22:23
  • You should be able to install PAR::Packer on ActivePerl with `cpan` instead of `ppm`. – stevenl Mar 24 '13 at 01:12