making perl executables on windows - perl

hi experts,
I want to make a executable from simple perl script in dir D:\script.pl (just prints hello world)
I want to do this using PAR::pp. I have installed it using cpanm PAR.
Could someone show actual steps. As i tried pp -o name.exe D:\script.pl both in cmd prompt and padre, but no success. Error : pp is not recognized as internal or external command . . .
Also there are some more questions, which I want to discuss, but want to clear above one first.
System info : Windows 7, 32 bit, PAR 1.007 , Strawberry perl 5 v14 sub ver2 v5.14.2. Padre IDE.
Does PAR archive mean a set up file?

pp doesn't actually come with PAR anymore, you must install the PAR::Packer distribution to get that.

Related

Perl Module install error CPAN Spreadsheet::ParseExcel

hi am trying to install perl module from cpan in my windows machine am getting below error after hitting two times yes .
Checking if your kit is complete...
Warning: the following files are missing in your kit:
README
Please inform the author.
Writing Makefile for Digest::Perl::MD5
'nmake' is not recognized as an internal or external command,
operable program or batch file.
nmake -- NOT OK
Running make test
Can't test without successful make
Running make install
make had returned bad status, install seems impossible
Running make for D/DO/DOUGW/Spreadsheet-ParseExcel-0.65.tar.gz
Is already unwrapped into directory C:\Perl\cpan\build\Spreadsheet-ParseExcel
0.65
CPAN.pm: Going to build D/DO/DOUGW/Spreadsheet-ParseExcel-0.65.tar.gz
'nmake' is not recognized as an internal or external command,
operable program or batch file.
nmake -- NOT OK
Running make test
Can't test without successful make
Running make install
make had returned bad status, install seems impossible
>perl exceltoxml.pl
Can't locate Spreadsheet/ParseExcel.pm in #INC (#INC contains: C:/Perl/site/lib
C:/Perl/lib .) at exceltoxml.pl line 4.
BEGIN failed--compilation aborted at exceltoxml.pl line 4.
I have tried 5 times.
nmake' is not recognized as an internal or external command
Sinan Ünür is right. The error message is that you don't have nmake installed. This means you are attempting to compile code (probably C code) and there's no C compiler or Make program.
A while ago, I would tell people that ActiveState doesn't fully support cpan because it can't compile code. ActiveState uses it's own pre-compiled packages available via the Perl Package Manager (PPM) which can be used from the command line or from a GUI interface. If a package isn't available via the PPM and it requires compilation, you were just out of luck. I would usually recommend Strawberry Perl instead of ActivePerl for this very reason. Strawberry Perl comes with the complete MinGW environment needed for those compilable CPAN modules.
However, about a half a dozen years ago, ActiveState put together an installable PPM package for the MinGW environment. Once this is installed, ActivePerl can use CPAN.
So you have two solutions:
Install this PPM package as Sinan Ünür mentioned in his answer. Then, try Spreadsheet::ParseExcel again.
Install Strawberry Perl instead of ActiveState's Perl. Strawberry Perl seems to be more compatible with the version of Perl found on Unix/Mac/Linux systems. Then try installing the Spreadsheet::ParseExcel package.
Okay, three solutions: Install Cygwin which will give you the complete Linux Environment on your Windows machine. It can take about two hours to install, but it comes with all of the GNU utilities you've known and love, most other Unix/Linux utilities, and the BASH shell.
It's what a lot of Linux/Unix homeboys use when they get sick of that ol' C:\> prompt. Cygwin comes with the latest version of Perl and works with every single CPAN package I've tried. There are a few minor issues (Like Termcaps) where things don't quite work the way they're suppose to, but I'm generally happy with it. It even comes with X11 and allows you to run XWindow apps, and even use XWindow apps across systems -- just like a REAL operating system does!
There maybe a few instances where CPAN modules may still have issues on Windows. One has to do with archiving and unarchiving modules and the missing libz library. However, installing this MinGW package (or using Strawberry Perl or Cygwin) will solve about 95% of the cpan installation issues.
I have tried 5 times.
Computers are deterministic things. That means, unless you change the conditions under which a program runs, it will always do the same thing (except, maybe, if there is a solar flare or an EMP).
So, there is no difference between issuing the same command once versus five times. If it failed the first time, ceteris paribus, it fill fail all five times.
That said, it looks like you installed ActiveState Perl, but did not install the MinGW package which provides the gcc & dmake based build tools.
So,
C:\>ppm install MinGW
and then try to install packages.
You also have the option of building your own perl using the Community Edition of Microsoft Visual Studio 2013 tools, or any other supported compiler.

Converting Perl script to EXE using Par Packer in Perl

I have converted an executable file using Perl Par Packer in Windows 7. But when I execute the file, it shows some error.
I think I have to add the module also, but I am not sure. I basically use pp -o sample.exe sample.pl
I use ActivePerl 5.16.
It's working fine as the Perl script, but after converting into an EXE file, it terminates with the error.
It seems that some required modules (ByteStreams.pm, Collection.pm, DOM.pm) are missing from your perl package.
Try to download and install them using ppm (perl package manager).
1. Press start Button , type perl
2. click on ppm logo
3. search module name from search box
4. Install.
If authorization failed try to install via command prompt.
open cmd.
type: ppm install 'module name'
rebuild your exe and run.
This issue is solved by adding the Mojo module in the same location of the standalone executing file
I like perl , and I also like C/C++. To make the best of both,
I wrote a github project to solve this issue.
please see:
https://github.com/tlqtangok/perlcpp
a short example is here :
P_eval("$a=2;$a=$a**10;");
Int("a") ; // a= 1024
P_eval("$a=qq(abc);
P_eval("#arr=(0..9);";
P_arr_Int_i("arr", 8 ); // => 8

PAR installation in perl cannot be completed

I desperately need your help! I need to compile a perl script to an executable so that it can be run in windows without having perl installed. I know it is not a good idea to do this , but I absolutely need it for the users of my script.
I have searched (a lot!) and decided the best solution is to use PAR::Packer. Yet I have been trying to install for something like 10 days now with no success… 
I ve tried all possible combinations of perl installation (activestate, strawberry, 5.10, 5.14, 5.16) and PAR versions, but I haven’t found the combination that really works….
I tried this link: http://www.nicholassolutions.com/tutorials/perl-PAR.htm
And this: http://www.rabbibob.com/index.php/PAR_Compiling_Perl_scripts_into_executables#Can.27t_find_par_loader
And various from this site..
Anyway, right now, I have installed (with the above instructions):
Strawberry perl 5.16.3001
PAR-1.007
The error I get now when I try to run
pp –o script.exe script.pl
is that:
pp is not recognized as an external or internal command, operable program or batch file
indeed I don’t find the relevant pp.bat in the bin. For earlier versions of par, this bat was created, although there other missing files were appearing when
running pp….
My path variable contains:
C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin
I also used PAR::Packer 1.0.14 but I get errors in the installation, something like
dmake.EXE: Error code 255, while making 'subdirs'
So, my question is: does anyone know a sure way this can work?? I am really frustrated and really pressed, every help will be deeply appreciated.
Thanks a lot!
I have used PAR to pack some scripts for other users. This has worked very well.
My old setup was done long ago. I have a new laptop and I tried to reproduce you error - but it seems like it just works.
My steps:
downloaded and installed strawberry-perl-5.18.1.1-64bit.msi
Install PAR::Packer with the cpan client
Create a testscript and type
pp -c -o test.exe test.pl
This produce the file test.exe - and it works fine.
the executable file pp is located in C:\strawberry\perl\site\bin\pp and was installed when i installed PAR::Packer.
If you cant find pp on you system you might want to check you installation of PAR::Packer.
I hope this helps :)

How can I compile my Perl script so it can be executed on systems without 'perl' installed?

I have a .pl file and I want to execute that file in any system even though perl is not installed. How can I achieve it?
What would be some good examples to do that?
pp can create an executable that includes perl and your script (and any module dependencies), but it will be specific to your architecture, so you couldn't run it on both Windows and linux for instance.
From its doc:
To make a stand-alone executable, suitable for running on a machine that doesn't have perl installed:
% pp -o packed.exe source.pl # makes packed.exe
# Now, deploy 'packed.exe' to target machine...
$ packed.exe # run it
(% and $ there are command prompts on different machines).
Install PAR::Packer. Example for *nix:
sudo cpan -i PAR::Packer
For Strawberry Perl for Windows or for ActivePerl and MSVC installed:
cpan -i PAR::Packer
Pack it with pp. It will create an executable named "example" or "example.exe" on Windows.
pp -o example example.pl
This would work only on the OS where it was built.
P.S. It is really hard to find a Unix clone without Perl. Did you mean Windows?
From perlfaq3's answer to How can I compile my Perl program into byte code or C?:
(contributed by brian d foy)
In general, you can't do this. There are some things that may work for your situation though. People usually ask this question because they want to distribute their works without giving away the source code, and most solutions trade disk space for convenience. You probably won't see much of a speed increase either, since most solutions simply bundle a Perl interpreter in the final product (but see How can I make my Perl program run faster?).
The Perl Archive Toolkit ( http://par.perl.org/ ) is Perl's analog to Java's JAR. It's freely available and on CPAN ( http://search.cpan.org/dist/PAR/ ).
There are also some commercial products that may work for you, although you have to buy a license for them.
The Perl Dev Kit ( http://www.activestate.com/Products/Perl_Dev_Kit/ ) from ActiveState can "Turn your Perl programs into ready-to-run executables for HP-UX, Linux, Solaris and Windows."
Perl2Exe ( http://www.indigostar.com/perl2exe.htm ) is a command line program for converting perl scripts to executable files. It targets both Windows and unix platforms.
Look at PAR (Perl Archiving Toolkit).
PAR is a Cross-Platform Packaging and
Deployment tool, dubbed as a cross
between Java's JAR and
Perl2EXE/PerlApp.
And let's not forget ActiveState's PDK. It will allow you to compile UI, command line, Windows services and installers.
I highly recommend it, it has served me very well over the years, but it is around 300$ for a licence.
Cava Packager is great on the Windows ecosystem.
Perl files are scripts, not executable programs. Therefore, for them to 'run', they are going to need an interpreter.
So, you have two choices:
1) Have the interpreter on the machine that you wish to run the script, or
2) Have the script running on a networked (or Internet) machine that you remotely connect to (ie with a browser)
On Mac OS X there may be perlcc. Type man perlcc. On my system (10.6.8) it's in /usr/bin. Your mileage may vary.
See perl-5.8.9 / perlcc.

Why can't Perl's PAR find the loadable object for Socket.pm?

I was using PAR::Packer to package my Perl application on Cygwin and then running it on HPUX.
A simple hello world works well, e.g.:
pp -p hello.pl
That results in a.par and then on HPUX:
parl a.par
It works great.
However when package a bigger application with many dependencies with -B bundle switch, no such luck, instead I get the error:
Can't locate loadable object for module Socket in #INC
Any ideas, maybe some problem with Windows/unix networking? Any fixes?
You're hitting this because Socket loads a shared library, and that's not portable across platforms (that is, the Socket shared lib on Windows won't work on Linux won't work on HPUX).
You could try two things:
Identify all the places you need shared libs, and have a native install of them on your target platform. You may also need to exclude those modules from your PAR archive.
Switch to pure-Perl implementations (which are (more) portable). If you're not a whiz at Perl, C, and your target platform, and a pure-Perl version is not already available, you may be out of luck with this.
The advantage of installing an actual perl on your HPUX is that your cygwin app can then run on the hpux perl. PAR packages aren't normally going to work between any two platforms. In my mind, it's not really any different than producing the hello.exe on cygwin and trying to run it on HPUX.
Perl blixtor's advice from comments I am moving the "edit updates" I had in the question to answer my own question here:
Most of the credit here goes to Andrew Barnett, the 2 key issues were the
native C code library
the perl LIB paths
Here were the steps I followed to get the cygwin created par to run on HPUX, I believe steps should be about same on any unix:
Followed Andrew's advice and removed IO::Socket with the pp -X IO::Socket switch, but then running the resulting parl on unix I get slightly modified but still related error:
Can't locate Socket.pm in #INC (#INC contains: CODE(0x406ab018) CODE(0x4055c880) CODE(0x40563978)) at Net/Config.pm line 11
even though running "perl -MCPAN -e shell" on the unix showed Socket should be installed and up to date:
cpan[2]> install IO::Socket
IO::Socket is up to date (1.30_01).
So in addition to excluding Socket with the -X switch abobe, I also had to create a wrapper script on HPUX with just this 1 line in in, wrapper.pl:
use PAR { file => 'bdiff.par', run => 'bdiff.pl' };
then to run this I didn't use parl, instead I would just call it with perl and I had to supply the entire paths to the default lib paths with the -I switch, like this:
perl -I/lib/perl5/lib/5.10.0/PA-RISC2.0 -I/lib/lib/site_perl wrapper.pl allparameters
for some reason when using parl it seems the default lib paths get excluded, hence the full paths above.
FWIW, PAR is not designed to be portable accross different platforms -- don't expect a par package created on cygwin to run on linux/hpux....