I need to run a perl program on Windows. I install Strawberry Perl.
I am not able to install Device::USB module.
Here is the revelant error in log :
-> OK
Successfully installed Inline-0.80
Installing C:\Dwimperl\perl\site\lib\MSWin32-x86-multi-thread\.meta\Inline-0.80\install.json
Installing C:\Dwimperl\perl\site\lib\MSWin32-x86-multi-thread\.meta\Inline-0.80\MYMETA.json
Configuring Device-USB-0.36
Running Makefile.PL
ERROR: Missing required environment variables to compile under Windows.
LIBUSB_LIBDIR should contain the path to the libusb libraries
LIBUSB_INCDIR should contain the path to the libusb include files
-> N/A
-> FAIL Configure failed f
As the error msg states, you should define the two environment variables LIBUSB_LIBDIR and LIBUSB_INCDIR.
Under windows on the command line you can add env vars (temporarily, for the currend cmd process) via SET name=value, e.g.: SET LIBUSB_LIBDIR=C:\your\path\to\the\libs.
Also, libusb has to be installed on your machine - maybe this also will set the lib&include path env vars permanently. (thx for comment! :)
First, you need to install the libusb library on your system.
Device-USB
This module provides a relatively complete Perl wrapper on the libusb
library. Using this module provides an object-oriented interface to any
installed USB devices.
Obviously, the module requires a copy of the libusb library compiled for the
target system. The module also requires a C compiler compatible with the
Perl installation, because it uses the Inline::C module to create the
interface to libusb.
Then, you need to tell Device::USB where to locate the library by setting env var LIBUSB_LIBDIR to the directory that contains the libusb DLL, and by setting env var LIBUSB_INCDIR to the directory that contains the libusb .h files.
You can set those env vars by right-clicking "My Computer", clicking "Properties", clicking "Advanced system settings", clicking "Environment Variables".
Related
Correct me if i'm wrong, but XS and Dynaloader based modules are those who use C/C++ shared objects (.so) and which are not PP (Pure Perl)?
Now assuming I have a machine, which does not have web-connectivity whatsoever (Solaris 10) and I want, for instance, to install Crypt::OpenSSL::AES (XS based module), copying the AES.pm file to the relevant path in #INC wont do any good since my system does not have libssl installed.
My second and most important question is, how do I install such modules when I don't have CPAN?
my approach is:
first get libssl for my platform, compile it, but where should I put that shard object file so that perl can find it?
when I have libssl installed and compiled and located where it should be, is it enough now to just copy the AES.pm to the relevant path in #INC, or do I need to configure / make it?
CPAN itself is part of the base perl install. It will always be available.
If you can't use the cpan shell to talk to the internet and fetch modules, you can at least grab the tarball from the CPAN website, put it on the target machine, untar it, then run
$ cpan .
from inside the unpacked directory. This will run the CPAN installer for that distribution. Of course if it finds missing dependencies, you'll have to fetch those yourself recursively using the same technique.
If you don't have root access I would install in ${HOME}/lib. Just make sure that the linker can find it, either the directory should be in you LD_LIBRARY_PATH environment variable, or better point EU::MM to the library and include files.
No, the module also have a part in C which has to be compiled.
To install
Download the distribution tarball: http://search.cpan.org/CPAN/authors/id/T/TT/TTAR/Crypt-OpenSSL-AES-0.02.tar.gz
Then follow the steps in the README file under INSTALLATION
perl Makefile.PL INC="-I $HOME/include" LIBS="-L $HOME/lib"
make
make test
make install
This will make sure that the module is correctly build, tested and installed.
I currently have XAMPP installed at C:\xampp. I currently have Activeperl installed at C:\Perl64.
How can I get my XAMPP server to utilize the library in activeperl instead of the built in library in xampp when executing perl scripts?
set your PERL5LIB environment variable to point into the ActivePerl lib directory.
I don't have the exact incantation for you. I switched from ActivePerl to Strawberry Perl this summer right after YAPC::NA.
If you have cgi/fastcgi application, it is good to point to your AP installation with shebang at the script top:
#!C:/Perl64/bin/perl.exe
The libraries will go along.
It might get more complicated if you have perl built into Apache with mod_perl, though.
Add environment variable PERL5LIB -> your lib path in user variables.Follow the below steps:
Right click on my computer and go to property
Click advanced system settings
Click Environment variables
In system variables click new
In variable name type PERL5LIB
In variable value type path to lib folder
Or run following for windows in command prompt:
set PERL5LIB=c:\code\lib
Or run following for Linux:
export PERL5LIB=/home/code/lib
Now open apache2\conf\httpd.conf in Notepad++ and do following changes
Add Perl library folder paths anywhere in the file.
SetEnv PERL5LIB C:/code/lib;C:/usr/site/lib;C:/usr/lib
save the config and restart the apache service.
Set the environment variable in httpd.conf. Like described in this post. Settings take effect after restarting Apache. I put this line:
SetEnv PERL5LIB=C:\Strawberry\perl\lib;C:\Strawberry\perl\site\lib
Worked great with Strawberry Perl.
I am attempting to install a Perl Module entitled: File-Copy-Recursive and I am following these steps:
1) open cmd.exe
2) perl -MCPAN -e 'install File::Copy::Recursive;'
and I receive the message "It looks like you don't have a C compiler and make utility installed. Trying to install dmake and the MinGW gcc compiler using the Perl Package Manager. This may take a few minutes..."
"Downloading ActiveState Package Repository packlist...failed 500 Can't connect to ppm4.activestate.com:80 (connect: timeout).
Downloading File-Copy-Recursive packlist...not found
ppm.bat install failed: Can't find any package that provides MinGW"
These failed because I am behind a proxy, and I do know the proxy settings but I don't know how to apply them in this situation.
Is anyone aware of any alternative fixes to this solution?
Thank you.
It seems you are using ActiveState Perl, which comes with its own package manager (called PPM) to ease the pain of installing modules, especially those which would normally require a C compiler to be able to install.
Try following the instructions to set up your environment so that PPM knows about your proxy. For example, to set the proxy settings for a single instance of cmd.exe:
C:\>set http_proxy=http://username:password#proxy.example.org:8080
Then, in the same command prompt window, try this (it works for me, though I'm not behind a proxy):
C:\>ppm install File-Copy-Recursive
Note that it's probably a good idea (maybe even required?) to run cmd.exe "As Administrator" to make sure it has full authorization.
EDIT: The particular module you want to use is written in pure Perl. For a quick "installation", you can just download it from CPAN, extract the files, and copy the "Recursive.pm" file into a File\Copy directory structure placed in the same directory as your script:
yourscript.pl
File\
Copy\
Recursive.pm
As an alternative you could try the Strawberry Perl distribution which comes with tools for building XS modules.
Hi
I guess you are using Activestate Perl
look at
http://docs.activestate.com/activeperl/5.10/faq/ActivePerl-faq2.html#what_is_ppm
PPM is installed automatically with ActivePerl.
To use PPM, your computer must be connected to the internet, have access to a PPM repository on a local hard drive or network share, or have access to a mounted ActiveState ActiveDVD.
If you connect to the internet via firewall or proxy, you may need to set the http_proxy environment variable. See PPM, Proxies and Firewalls for more information.
I am trying to compile a portable version of perl containing a CPAN module, specifically the YAML module. I intend to be able copy this portable version into my home directory on numerous Redhat Linux machines, add it to my $PATH and use this version instead of the default perl version to run some tests.
I have already managed to compile a portable version of perl and got it working on different machines. However, when I compile the YAML module and install it, it works locally but then fails when I copy it to other machines.
Here's my compilation steps locally for the YAML module
perl Makefile.pl
make test
make install
Which installs the YAML module locally and also works locally when I use the YAML module in a script.
This is the error once I copy perl to another machine and try to use the YAML module...
Can't locate loadable object for module YAML::XS::LibYAML in #INC
even though lib/site_perl/5.10.1/x86_64-linux/YAML/LibYAML.pm exists in my local copy.
Is what I'm attempting to do possible?
If so, where am I going wrong?
Possibly you should explore PAR with which you can create an archive of your module dependencies and ship it alongside your application.
I need to run Perl applications I develop on cygwin Windows on HP unix / Solaris hosts. I am not a superuser on the unix machines and I can't touch the default Perl module location nor can I install modules to the default Perl module location. Also the unix installation lacks most basic modules and I can't change that.
For example, I have a Perl application that needs Expect which has native C compiled parts to it. How would I roll out this application to unix with its required dependencies without having to install anything else on that box?
Is there way to build the entire Perl application under Cygwin Windows and then just roll out one executable to unix and run it from my home directory there?
EDIT addition based on answers so far:
Thanks in particular to brian, the local LIB dir solution seems to work in case of native Perl, but in case of Perl module needing C components, cross platform compiling, ie compiling on cygwin to run on Solaris, is not really possible as I feared.
However would having an other linux installation help, i.e. would this be possible easier between different flavors of Unix like package Perl on linux and then deploy to Solaris/HP? And what about something like lcc ?
Also I'd still like to hear little more if somebody has rolled out a native Perl package on Windows that includes all dependencies for a complicated Perl app that can then be moved to unix as just one file? (I do now understand that it won't work in case native C code is included like in in Expect.pm, but what about in case of app only using pure perl modules?)
Basically for many reasons I am trying to minimize time I need to spend being logged into these "production" unix hosts and do as much as possible locally beforehand.
Added a new cross-compile question, since I felt I was maybe veering too far from the original perl question.
EDIT -- Par looks promising for pure Perl, although same deal, it doesn't look to solve the cross platform compile problem for native extensions
In this case, I'd consider delivering a complete application complete with its own Perl. You get to choose any version you like and any modules you like. Compile everything, organize everything into a directory, then tar the result. To deploy, copy the file and untar. Use the advice that others have already noted about library search paths, etc. In essence, your application gets its own stack.
Now, the trick there is the cross compilation. Why are you developing on Cygwin? Is that a target too? Is there a reason you don't have an HP/UX or Solaris development machine? What architecture are you targeting (RISC, SPARC, Intel, etc). If you can't get hardware to run those, get some virtual machines for your targets and develop there.
Aside from that, you can install modules anywhere you have permissions. See perlfaq8:
How do I keep my own module/library directory?
How do I add the directory my program lives in to the module/library search path?
How do I add a directory to my include path (#INC) at runtime?
I haven't tried this particular feature, but perl2exe says it supports cross platform builds.
Compiling a Perl script with all its dependencies on Windows with Cygwin and running it Solaris is just not going to work.
Now the question is: do you have access to a compiler on that Solaris computer? It's not because you do not have root access that you cannot compile and install Perl modules in your home directory by using:
perl Makefile.PL PREFIX=$HOME
If you have CPAN available on your Solaris system you can set the prefix in the CPAN shell this way:
start the shell perl -MCPAN -e shell;
change the prefix with conf makepl_arg PREFIX=/path/to/your/home/directory
For your script to run, you can either start perl with the -I $HOME command-line switch, e.g.:
perl -I $HOME script.pl
Your other option would be to place this at the begining of your script
use lib $ENV{'HOME'};
Set your environment variable PERLLIB to your personnal Perl lib directory or use the -I command line switch to Perl to indicate it.
If you have access to the HP-UX machine you can compile Expect there and install it in your directory. But cross compilation from Windows to HP-UX is probably much more difficult. You would have to build a GCC cross compiler.
If you have a compiler on each of your systems (and some other tools needed by configure like grep), you should not only be able to compile modules, but you should also be able to build your own perl executables.
You'll want local::lib. Once you've done that, the pure Perl modules should work cross platform, but you'll have to identify and reinstall the compiled modules on the foreign platform. Do the initial install on a real unix, cpan on cygwin is slow.
I've run across this several times on my work systems. We have a base install of Perl 5.8 and I don't have the ability to add modules. Here's the solution I use:
Create a folder called 'lib' in your
project root (ex:
~/projects/MyProject/lib)
Any
modules you download from CPAN
should have a Makefile as well as a
directory called "lib". Copy the contents of the lib folder into your newly created lib folder. Some modules may only contain a single .pm file, and no lib structure. Just copy the .pm file.
Your code should do the following: first, use any modules that have been installed normally, then unshift your #INC environment variable to use your local libraries:
# Declare Includes --------------------------------------------------------------------------------
use Getopt::Long;
use vars qw($VERSION);
use DirHandle;
use FileHandle;
# Force perl to use our local 'lib' directory for imported modules, this allows us to
# use modules without having to install them in th emain perl assembly. However, this
#also prevents these modules from being used in other projects.
BEGIN { unshift #INC, "lib"; }
use Error qw(:try);
use SOAP::Transport::HTTP;
#use LWP::Protocol::https;
use XML::Simple;
use XML::Writer;
use XML::Writer::String;
The caveat to this method is that some Perl modules don't use the 'lib' method or have additional dependencies. If you run into problems, examine the Makefile.PL for the module and see what it's doing.