I am trying to convert my Perl script to standalone exe.
I assume perl2exe is a tool that serves this purpose. More or less.
When I am trying to generate the exe file, I am getting library issues.
One of the library issues is:
Warning: Can't locate VMS/Stdio.pm
at C:\Perl\lib\File\Temp.pm line 19
#INC = C:\Perl\site\lib, C:\Perl\lib, ., C:\Perl\lib\Digest, must be directory, not file)
When I went to line 19 of Temp.pm, the line is written as follows:
require VMS::Stdio if $^O eq 'VMS';
But,my OS is MSWin32.
I am coming to a conclusion that, perl2exe is not compiling the script properly. Its reading my OS wrong.
Sample script is as follows:
my_libraries.pl
use Tk;
use lib 'C:\Perl\lib\Digest';
use strict;
use strict;
use warnings;
use strict;
use warnings;
use LWP::Simple qw(getstore);
use LWP::UserAgent;
use Digest::MD5 qw( md5_hex );
use Digest::MD5::File qw( file_md5_hex );
use File::Fetch;
use WWW::Mechanize ;
use Tk::ErrorDialog;
c:\perl2exe\perl2exe-16.00-Win> perl2exe my_libraries.pl my_libraries.exe
Warning: Can't locate File/BSDGlob.pm
at C:\Perl\lib\File\GlobMapper.pm line 13
#INC = C:\Perl\site\lib, C:\Perl\lib, ., C:\Perl\lib\Digest, must be directory, not file)
Warning: Can't locate Digest/Perl/MD5.pm
at C:\Perl\lib\Digest\MD5.pm line 30
#INC = C:\Perl\site\lib, C:\Perl\lib, ., C:\Perl\lib\Digest, must be directory, not file)
Warning: Can't locate VMS/Stdio.pm
at C:\Perl\lib\File\Temp.pm line 19
#INC = C:\Perl\site\lib, C:\Perl\lib, ., C:\Perl\lib\Digest, must be directory, not file)
Warning: Can't locate VMS/DCLsym.pm
at C:\Perl\lib\IPC\Cmd.pm line 227
#INC = C:\Perl\site\lib, C:\Perl\lib, ., C:\Perl\lib\Digest, must be directory, not file)
Warning: Can't locate VMS/Filespec.pm
at C:\Perl\lib\ExtUtils\Manifest.pm line 31
#INC = C:\Perl\site\lib, C:\Perl\lib, ., C:\Perl\lib\Digest, must be directory, not file)
Warning: Can't locate HTML/FormatText.pm
at C:\Perl\lib\HTML\Element.pm line 1297
#INC = C:\Perl\site\lib, C:\Perl\lib, ., C:\Perl\lib\Digest, must be directory, not file)
Sorry. let me put my obvious question here:
Why is perl2exe giving library issues which are not intended to come? Is it a bug in perl2exe or am I doing something wrong?
I mean, you can see in line 19 that if the OS is 'VMS', then stdio.pm is required. My os is 'MSWin32'.
I tried a to z possible remediation to make the perl2exe work. I removed the sections that was producing warnings (Hacked the modules). Studied and tried various flags. I have to say it is not at all feasible to convert Perl programs using diverse modules to exe files using perl2exe.
I found a software that exactly did what I wanted- Cava Packager.
It took sometime to find the below page-
How can I package my Perl script to run on a machine without Perl?
It converted my Perl program to Exe and also generated an installation file. Awesome.
Thanks,
Anoop.
The problem is
C:\Perl\lib\File\Temp.pm line 19
Open the file you will see this
require VMS::Stdio if $^O eq 'VMS';
Change the file not read-only, then place # for this line, go back to perl2exe the file again, then it should be gone.
It may be of interest to readers of this issue that in addition to the VMS/Stdio.pm error, I also received "Can't locate the.pm". The line in my perl code that it pointed to was the text "Use the 't' command..." that was inside a double-quoted print statement. Apparently perl2exe looked for the 'use' statement regardless of where in my code it appeared. The fix was to either re-word the text to remove the word 'use' or put the text in single quotes.
Related
I'm trying to run a perl script that is located in a remote linux server from windows using the python program. I'm using the subprocess.call method.
This is the python line of code
returnCd = subprocess.call(['plink', '-ssh', \
'%s#%s' %('******','*****.***.com'), '-pw', '****', \
'perl', '/apps/CACSGDEV/springbatch/perlscript/DEBTOR_VERIFICATION.pl'], \
shell=True)
And this is what i see in the console (broken over lines for readability)
Can't locate ENVRC.pl in #INC (#INC contains: /usr/local/lib64/perl5
/usr/local/share/perl5 /usr/lib64/perl5/vendor_perl
/usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .)
at /apps/CACSGDEV/springbatch/perlscript/DEBTOR_VERIFICATION.pl line 16.
The file DEBTOR_VERIFICATION.pl has the following # line 16
require "ENVRC.pl";
The file ENVRC.pl is in the same path as that of the DEBTOR_VERIFICATION.pl. Can anyone please suggest?
The program DEBTOR_VERIFICATION.pl is directly executed and thus it doesn't need to have its directory in #INC. On the other hand, when a file need be loaded via require (or use, which uses require) then it is precisely the directories in #INC that are searched for it. Since /apps/.., where ENVRC.pl resides, is not there the file cannot be found.
You need to add that directory to #INC and a good way to do it is via lib pragma
use warnings;
use strict;
...
use lib "/apps/CACSGDEV/springbatch/perlscript";
...
But if this program (DEBTOR_VERIFICATION.pl) and the required file ENVRC.pl will always stay in the same directory it is better to use FindBin instead of hard coding the path
use warnings;
use strict;
...
use FindBin qw($RealBin);
use lib $RealBin;
In either case the files in that directory can now be found by use and require (and do).
The DEBTOR program works when executed right from its directory, in older Perls, since the . (the current working directory) used to be included in #INC by default. We see that this is the case from #INC printed in the error message. So . gets searched and ENVRC.pl is found.
Relying on that has really always been a bad practice, but as of perl v5.26.0 (perldelta) (May 2017) the . directory is not in #INC anymore.
So you should add the above use lib statement to the DEBTOR... program anyway.
I need to keep any custom modules in the same-ish directory as my script.
I keep getting this error suggesting that Perl can't "see" the module I'm declaring
Global symbol "$employment_type" requires explicit package name at early_enrollments_by_term.pl line 260.
Execution of early_enrollments_by_term.pl aborted due to compilation errors.
My module is Hash.pm and is in directory /home/pgb2/canvas/canvas-sis-feeds/scripts/lib/Custom
Hash.pm
package Custom::Hash;
My script is early_enrollments_by_term.pl and lives in /home/pgb2/canvas/canvas-sis-feeds/scripts/
early_enrollments_by_term.pl
#!/usr/bin/perl
use strict;
use DBI;
use lib qw(/home/pgb2/canvas/canvas-sis-feeds/scripts/lib);
use Custom::Hash;
my $enrollment_type = $Custom::Hash::enrollment_hash{$role}; # line 259
print "\nenrollment_type: $employment_type\n"; # line 260
Would anyone be able to tell why it's not finding the module?
Although you have shown very little of your code,
the problem would presumably be that you have declared $enrollment_type and tried to use $employment_type, which has not been declared
Had perl been unable to find the module, it is the use Custom::Hash statement that would throw the error
I'm am currently trying to download a program that has given me many issues. I'm running cygwin on Windows. The program should run correctly and the installation packages were all installed in an administrator terminal shell, and as the program was being un'tar'ed no errors were thrown. However after the installation the program cannot find the #INC module named FASTA in the file system
rpbas#DESKTOP-4LMFDCK /cygdrive/c/Users/rpbas/Documents/Work/OliveraLab/signal-4.1
$ ./signal -t euk -f short test/euk10.fsa > euk10.fsa.short_out Can't locate FASTA.pm in #INC (you may need to install the FASTA module)
(#INC contains:
/cygdrive/c/Users/rpbas/Documents/Work/Olivera\ Lab/signal-4.1/lib
\cygdrive\c\Users\rpbas\Documents\Work\Olivera/ Lab\signal-4.1
/usr/local/lib/perl5/site_perl/5.26/x86_64-cygwin-threads
/usr/local/share/perl5/site_perl/5.26 /usr/lib/perl5/vendor_perl/5.26/x86_64-cygwin-threads
/usr/share/perl5/vendor_perl/5.26
/usr/lib/perl5/5.26/x86_64-cygwin-threads /usr/share/perl5/5.26)
at ./signal line 60.
BEGIN failed-- compilation aborted at ./signal line 60.
However, the ./lib/FASTA.pm file clearly exists and being directed to.
rpbas#DESKTOP-4LMFDCK /cygdrive/c/Users/rpbas/Documents/Work/Olivera\ Lab/signal-4.1/lib
$ ls
FASTA.pm
The code includes the line (at the beginning)
BEGIN {
$ENV{SIGNAL} = '/cygdrive/c/Users/rpbas/Documents/Work/Olivera\ Lab/signal-4.1';
}
and at line 60
use lib "$ENV{SIGNAL}/lib";
use FASTA;
I've been working on this issue for a couple of days now and it a big bottleneck to the other parts of my program. Any help would be appreciated!
You are getting tripped up by the quote interpolation rules of Perl. Inside single quotes, a backslash character only acts as an "escape" character when it is followed by a single quote or by another backslash. In all other cases, it is interpreted as a literal backslash.
If you printed out $ENV{SIGNAL} you would see something like
/cygdrive/c/Users/rpbas/Documents/Work/Olivera\ Lab/signal-4.1
including the backslash character. Don't escape the space and you should be all right.
BEGIN {
$ENV{SIGNAL} =
'/cygdrive/c/Users/rpbas/Documents/Work/Olivera Lab/signal-4.1';
}
#INC contains
/cygdrive/c/Users/rpbas/Documents/Work/Olivera\ Lab/signal-4.1/lib
when it should contain
/cygdrive/c/Users/rpbas/Documents/Work/Olivera Lab/signal-4.1/lib
You could replace
BEGIN {
$ENV{SIGNAL} = '/cygdrive/c/Users/rpbas/Documents/Work/Olivera\ Lab/signal-4.1';
}
use lib "$ENV{SIGNAL}/lib";
with
BEGIN {
$ENV{SIGNAL} = '/cygdrive/c/Users/rpbas/Documents/Work/Olivera Lab/signal-4.1';
}
use lib "$ENV{SIGNAL}/lib";
but a better solution is to replace it with
use FindBin qw( $RealBin );
use lib ( $ENV{SIGNAL} || $RealBin ) . "/lib";
I'm new to both Perl and its feature of .lib.
I made this simple subroutine and saved it as a file with an extension of .lib
sub shorterline {
print "Content-type: text/html\n\n";
}
1;
As I tried to insert the subroutine into the Perl file with an extension of .cgi below, it doesn't work somehow:
#!/usr/bin/perl
require 'mysubs.lib';
&shorterline;
print "Hello, world!";
I gave the .cgi the chmod permission, but the .cgi still doesn't work, what seem to be the problem ?
Your descriptions of what the problem is are rather unclear.
it doesn't work somehow
the .cgi still doesn't work
Without knowing what problems you're seeing, it's hard to know what the problem is. But I tried copying your code and running the program from the command line and I got this error message:
Can't locate mysubs.lib in #INC (#INC contains: ...)
So I think you are using a recent version of Perl and are running up against this change:
Removal of the current directory (".") from #INC
The perl binary includes a default set of paths in #INC. Historically it has also included the current directory (".") as the final entry, unless run with taint mode enabled (perl -T). While convenient, this has security implications: for example, where a script attempts to load an optional module when its current directory is untrusted (such as /tmp), it could load and execute code from under that directory.
Starting with v5.26, "." is always removed by default, not just under tainting. This has major implications for installing modules and executing scripts.
If this is the problem, then you can fix it by adding the script's directory to #INC as follows:
use FindBin qw( $RealBin );
use lib $RealBin;
before your call to require. If that doesn't solve your problem, perhaps you would consider sharing a little more detail about the problems that you are experiencing.
I am trying to install Lingua::Lid onto a unix system (ubuntu, latest version). Of course I am root. When I go into the package to install using perl Makefile.PL I get this dumb error:
[root#csisl27 Lingua-Lid-0.01]# perl Makefile.PL
/opt/ls//lib does not exist at Makefile.PL line 48.
I have tried playing with the path on line 48, nothing changes, here is what line 48-50 looks like:
Line 48: die "$BASE/lib does not exist" unless -d "$BASE/lib";
Line 49: die "$BASE/include does not exist" unless -d "$BASE/include";
Line 50: die "lid.h is missing in $BASE/include" unless -e "$BASE/includ/lid.h";
The variable $BASE is declared as this:
$BASE = "/opt/ls/" if ($^O eq "linux" or $^O eq "solaris");
$BASE = "/usr/local/" if ($^O eq "freebsd");
$BASE = $ENV{LID_BASE_DIR} if (defined $ENV{LID_BASE_DIR});
Now the Perl program I am trying to write simply look like this (just my base):
#!/usr/bin/perl
use Lingua::LinkParser;
use strict;
print "Hello world!\n";
When I run this trying to use Lingua, here is my error:
[root#csisl27 assign4]# ./perl_parser_1.pl
Can't locate Lingua/LinkParser.pm in #INC (#INC contains: /usr/lib/perl5/site_perl/5.10.0/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.10.0 /usr/lib/perl5/vendor_perl/5.10.0/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.10.0 /usr/lib/perl5/5.10.0/x86_64-linux-thread-multi /usr/lib/perl5/5.10.0 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl .) at ./perl_parser_1.pl line 3. BEGIN failed--compilation aborted at ./perl_parser_1.pl line 3.
I tried insalling this from cpan, still doesn't properly work.
Here is where the trouble begins when building Lingua::LinkParser:
LinkParser.xs:5:27: error: link-includes.h: No such file or directory
I think you need to install Link Grammar first.
If you look at the Makefile.PL that comes with the distribution, you can see the following comments:
# 'LIBS' => "-L/dbrian/link-grammar-4.4.3/link-grammar/.libs/ -llink-grammar",
# 'INC' => "-I/dbrian/link-grammar-4.4.3/link-grammar/"
which means (very indirectly) that you either do not have Link Grammar installed on your system or it is installed in a non-standard location. If it is not installed, install it first. If it is installed, specify the correct location for INC and LIBS.
As the README states:
Before you build this package, it is highly recommended that you install
the link parser package with make install, which will put the libs,
headers, and dictionary files in standard locations. This build no longer
prompts for package directories, so if you want to build with non-standard
locations, you'll need to edit Makefile.PL to make that happen.
In particular, pay attention to the INCLUDE parameter.
The Lid library is needed as prerequisite for Lingua::Lid. You did not install it. Buy it from its vendor: http://www.lingua-systems.com/request-quote/index.html?product=lid