Newbie: Perl script to Windows and Linux executable versions.

H

Harry

ExtUtils::Embed comes with the perl distribution, so something's gone
wrong with yours. What happens if you run

    perl -MExtUtils::Embed -e1

I see this message:
$ perl -MExtUtils::Embed -e1
Can't locate ExtUtils/Embed.pm in @INC (@INC contains: /usr/local/
lib/perl5/site_perl/5.10.0/i386-linux-thread-multi /usr/local/lib/
perl5/site_perl/5.10.0 /usr/lib/perl5/vendor_perl/5.10.0/i386-linux-
thread-multi /usr/lib/perl5/vendor_perl/5.10.0 /usr/lib/perl5/
vendor_perl /usr/lib/perl5/5.10.0/i386-linux-thread-multi /usr/lib/
perl5/5.10.0 /usr/lib/perl5/site_perl .).
BEGIN failed--compilation aborted.

Do you actually have an ExtUtils\Embed.pm
anywhere in your perl installation?

I don't seem to have ExtUtils/Embed.pm anywhere. Here's, e.g., what I
see:
$ find /usr/local/lib/perl5/ /usr/lib/perl5/ -iname '*embed*'
/usr/lib/perl5/5.10.0/i386-linux-thread-multi/CORE/embedvar.h
/usr/lib/perl5/5.10.0/i386-linux-thread-multi/CORE/embed.h
/usr/lib/perl5/5.10.0/pod/perlembed.pod

What does perl -V say?

$ perl -V
Summary of my perl5 (revision 5 version 10 subversion 0)
configuration:
Platform:
osname=linux, osvers=2.6.18-128.1.14.el5, archname=i386-linux-
thread-multi
uname='linux x86-7.fedora.phx.redhat.com 2.6.18-128.1.14.el5 #1
smp mon jun 1 15:52:58 edt 2009 i686 i686 i386 gnulinux '
config_args='-des -Doptimize=-O2 -g -pipe -Wall -Wp,-
D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-
size=4 -m32 -march=i586 -mtune=generic -fasynchronous-unwind-tables -
Accflags=-DPERL_USE_SAFE_PUTENV -Dversion=5.10.0 -
Dmyhostname=localhost -Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red
Hat, Inc. -Dprefix=/usr -Dvendorprefix=/usr -Dsiteprefix=/usr/local -
Dprivlib=/usr/lib/perl5/5.10.0 -Dsitelib=/usr/local/lib/perl5/
site_perl/5.10.0 -Dvendorlib=/usr/lib/perl5/vendor_perl/5.10.0 -
Darchlib=/usr/lib/perl5/5.10.0/i386-linux-thread-multi -Dsitearch=/usr/
local/lib/perl5/site_perl/5.10.0/i386-linux-thread-multi -Dvendorarch=/
usr/lib/perl5/vendor_perl/5.10.0/i386-linux-thread-multi -
Dinc_version_list=none -Darchname=i386-linux-thread-multi -Duseshrplib
-Dusethreads -Duseithreads -Duselargefiles -Dd_dosuid -Dd_semctl_semun
-Di_db -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -
Duseperlio -Dinstallusrbinperl=n -Ubincompat5005 -Uversiononly -
Dpager=/usr/bin/less -isr -Dd_gethostent_r_proto -
Ud_endhostent_r_proto -Ud_sethostent_r_proto -Ud_endprotoent_r_proto -
Ud_setprotoent_r_proto -Ud_endservent_r_proto -Ud_setservent_r_proto -
Dscriptdir=/usr/bin -Dotherlibdirs=/usr/lib/perl5/site_perl'
hint=recommended, useposix=true, d_sigaction=define
useithreads=define, usemultiplicity=define
useperlio=define, d_sfio=undef, uselargefiles=define,
usesocks=undef
use64bitint=undef, use64bitall=undef, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -
DPERL_USE_SAFE_PUTENV -DDEBUGGING -fno-strict-aliasing -pipe -I/usr/
local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/
include/gdbm',
optimize='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -
fstack-protector --param=ssp-buffer-size=4 -m32 -march=i586 -
mtune=generic -fasynchronous-unwind-tables',
cppflags='-D_REENTRANT -D_GNU_SOURCE -DPERL_USE_SAFE_PUTENV -
DDEBUGGING -fno-strict-aliasing -pipe -I/usr/local/include -I/usr/
include/gdbm'
ccversion='', gccversion='4.4.0 20090506 (Red Hat 4.4.0-4)',
gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define,
longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='gcc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lresolv -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -
lc
perllibs=-lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
libc=/lib/libc-2.10.1.so, so=so, useshrplib=true,
libperl=libperl.so
gnulibc_version='2.10.1'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -
Wl,-rpath,/usr/lib/perl5/5.10.0/i386-linux-thread-multi/CORE'
cccdlflags='-fPIC', lddlflags='-shared -O2 -g -pipe -Wall -Wp,-
D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-
size=4 -m32 -march=i586 -mtune=generic -fasynchronous-unwind-tables -L/
usr/local/lib'


Characteristics of this binary (from libperl):
Compile-time options: DEBUGGING MULTIPLICITY PERL_DONT_CREATE_GVSV
PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP
PERL_TRACK_MEMPOOL PERL_USE_SAFE_PUTENV
USE_ITHREADS
USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API
Built under linux
Compiled at Jul 7 2009 09:55:34
@INC:
/usr/local/lib/perl5/site_perl/5.10.0/i386-linux-thread-multi
/usr/local/lib/perl5/site_perl/5.10.0
/usr/lib/perl5/vendor_perl/5.10.0/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.10.0
/usr/lib/perl5/vendor_perl
/usr/lib/perl5/5.10.0/i386-linux-thread-multi
/usr/lib/perl5/5.10.0
/usr/lib/perl5/site_perl
 
H

Harry

There's your problem. Red Hat's perl packages are known to be broken:
the package called 'perl' doesn't actually install the whole of the perl
distribution. I believe you need to install the 'perl-core' package. See
also
http://www.mail-archive.com/[email protected]/msg12210.html .

Red Hat has a very poor history with their perl packages, though I
believe they are trying to fix that (Tom Callaway in particular seems to
be making an effort to work with p5p and sort out the issues). For now I
would still always recommend you build your own perl for any serious
work.

Ben 'Angel' Morrow.
I had _no_ idea this could've been / was going on. Thanks, Ben, for
enlightening.

Just for the information of all you helpful posters (on this thread)
and other members of this group... I managed to 'somewhat install'
PAR::packer but not without hiccups.
1. I first got a exit status of 512 and a "won't make", "won't test"
error.
2. I then tried to manually do the install by...
2.1 cd-ing into ~/.cpan/build/PAR-Packer* dir.
2.2 Issuing a 'perl Makefile.PL'.
2.3 Followed by a 'make test' and 'make install'.

Things seemed to look fine at this point:
cpan[3]> install PAR::packer
PAR::packer is up to date (0.991).

However, when I try to actually use the Par Packer command pp (see
'man pp' for details), this is what I see:
$ which pp
/usr/local/bin/pp

$ pp -o hello.exe hello.pl
Can't locate PAR/Packer.pm in @INC (@INC contains: /usr/local/lib/
perl5/site_perl/5.10.0/i386-linux-thread-multi /usr/local/lib/perl5/
site_perl/5.10.0 /usr/lib/perl5/vendor_perl/5.10.0/i386-linux-thread-
multi /usr/lib/perl5/vendor_perl/5.10.0 /usr/lib/perl5/vendor_perl /
usr/lib/perl5/5.10.0/i386-linux-thread-multi /usr/lib/perl5/5.10.0 /
usr/lib/perl5/site_perl .) at /usr/local/lib/perl5/site_perl/5.10.0/
pp.pm line 5.
BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/
5.10.0/pp.pm line 5.
Compilation failed in require at /usr/local/bin/pp line 8.
BEGIN failed--compilation aborted at /usr/local/bin/pp line 8.

When I look for PAR-related stuff in my Perl installation, this is
what I see:
$ find /usr/local/lib/perl5/ /usr/lib/perl5/ -name '*PAR*'
/usr/local/lib/perl5/site_perl/5.10.0/App/Packer/PAR.pm
/usr/local/lib/perl5/site_perl/5.10.0/i386-linux-thread-multi/auto/PAR
/usr/local/lib/perl5/site_perl/5.10.0/PAR.pm
/usr/local/lib/perl5/site_perl/5.10.0/PAR
/usr/local/lib/perl5/site_perl/5.10.0/PAR/StrippedPARL
 
P

Peter J. Holzer

Well the original dependencies reported by cpan program were:
Archive::Zip
Getopt::ArgvFile
Module::ScanDeps
PAR
PAR::Dist
I installed them all one by one. Manually. Via cpan. This step was
successful.

Why do you install them manually via cpan? The cpan program
automatically resolves all the dependencies and installs the necessary
modules for you.

I'm a bit confused about what you want.
[...]
I want to handover this Perl script to another person (outside
development). This another person could be field personnel, or even a
customer. I don't want my logic to be leaked to anyone outside my
development team. Hence the need to have a binary EXE for Windows and
an ELF for Linux that a non-developer could use without needing to
install Perl on their machines

This is what PAR::packer does, but ...
and, more importantly, without knowing what I'm doing inside.

... it doesn't do this. PAR::packer just packages your script together with
the necessary modules and a perl interpreter into an executable. When
you run that executable it first unpacks everything again (into
/tmp/par-$LOGNAME/cache-$HASH on Linux) and then runs the script. So it
is easy to find out for the user of the program "what you are doing
inside".
Of course, hackers can reverse engineer logic from EXE/ELF but I can
live with that; I only want to make it difficult for casual hackers.

The options --clear and --filter may help you to make it a little harder
for the casual hacker. But I doubt you can make it really difficult.

(oh, and by the way: For Windows, I hear there are really good reverse
engineering tools[1] - so compiling to machine code still wouldn't make
it very difficult for the a-bit-more-than-casual hacker)


hp
 
J

Jürgen Exner

Harry said:
[...] I don't want my logic to be leaked to anyone outside my
development team.

Why didn't you say so in the beginning?
See "perldoc -q hide"

jue
 
J

January Weiner

Hey folks,

I have a perl script that I'd like to be able to run on Windows and
Linux. Is this easily possible?

Here is how I normally do it.

1) I have a Linux and a Windows installation, both with a full Perl
installation. I make sure that my script works on both installations.
Note that the Windows installation is usually just a virtualbox with
Windows on it, sharing the perl script folder with the host Linux
machine.

2) The only additional Perl module I use is the perl packer (PAR::packer)
which comes with the "pp" utility (pp.exe on Windows). I use this to
construct the executables. I run it on the Linux machine and on the
Windows machine separately.

pp -o hello hello.pl

or

pp.exe -o hello.exe hello.pl

3) test this on a Windows machine (again, a virtualbox) without perl
installation. Presto.

This works really well except for the long startup times for even small
scripts. However, it does work and I have not found a better solution.

j.
 
M

MSwanberg

What I want is
    an EXE for Windows, and
    an ELF for Linux
each of which runs without any dependence on the Perl installation.

Thanks, RGB (for taking the time to write)!

I think you were on the right track with PAR. Check out Hack #40 in
the book "Perl Hacks". I've not done it myself but it will walk you
through making self-extracting PARs that can be executed.

-Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top