XAMPP - Change #INC path to direct to Activeperl 5.12.2 LIB - perl

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.

Related

Need help for cpan installation and module directory

I'm trying to install perl module. But, I have this error:
"Can't find C:\Strawberry\perl\bin\cpan.bat on PATH, '.' not in PATH".
And, when I use cpan from strawberry directory and try to install module, perl can't find it.
Please confirm these process done by you in your machine.
Go the System properties and Click ENVIRONMENT Variables
Add your Strawberry perl path in USER variables C:\Strawberry\perl\bin
Add your Strawberry perl path in SYSTEM variables C:\Strawberry\perl\bin
I hope this is clear for you.

Not able to install the Perl module Device::USB on Windows

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".

Perl - Use lib with perl module which have dependencies

I have a Perl script which uses the module Net::SSH::Any. Since it does not belong to the “default” Perl installation, I have to use the use lib functionality to include it in my script.
Now, I have the directory c:\lib\net\ssh\any\ on my drive and I specify this: use lib c:/lib; at the beginning of my script.
It “works”: it didn’t say that the module is missing but it says that it couldn’t locate auto/Net/SSH2/autosplit.ix and at the end no backend available at...
When I add the auto directory (containing the correct structure) in the c:\lib\ directory and launch the script, I get this error:
No backend available at...
Which is an internal error of Net::SSH::Any mentioning it could not access the backend directory (which is already included :/)
Does anyone know how to solve something like that? I hope I was clear enough.
You need to use Local::Lib.
This will let you install and load a whole bunch of libraries and their dependencies in an alternate location. I use cpanm to manage my modules and a command something like this (which I put in a wrapper script).
cpanm -L $cpandir $M --no-skip-installed
Where $cpandir is your locallibdir and $M is the module you are trying to install.
Then in your code you would specify
use local::lib '~/foo';
However, I recommend setting a PERL5LIB environment variable, which will append your custom location to #INC and make the extra use local::lib line unnecessary. You would typically edit .bashrc or .profile in your home directory with a line like:
export PERL5LIB=/home/myusername/mymods/
The issue was caused by the fact that the module was downloaded and installed on a 32bits windows but I tried to run it on a perl 64bits installation! So the Net::SSH2 required module couldn't be executed properly.
To resume:
-How to detect the issue: by executing this command: (thanks to Salva)
"perl -Ic:\lib -MNet::SSH2 -e1"
-Modules definitions in my script:
use lib 'c:\lib';

unable to run php cli from the command line when xampp portable is installed in another drive

I have installed a xampp portable package on my drive D, added the php folder path inside it on the system environment so I would be able to run php basically anywhere from the command line. but when i try to check if its working by executing the "php -v" command, it runs but i get this following error/warning messages.
"Warning: PHP Startup: Unable to load dynamic library 'xampp-portable\php\ext[:any].dll - The specified module could not be found."
*the [:any] there just means some dll filename.
and i get a lot of that warnings with just varying dll filenames,
anyway, here's the catch. when i do change my current path in the command line to somewhere in drive D, and then run the same command "php -v" it runs smoothly.
so what configuration should i do to fix this problem?
by the way, i do the same with mysql, putting its bin directory path on the system enviroment, run it in both inside drive C and drive D. and it runs smoothly. so i guess this problem is only on php.
I've posted the same question in xampp forums and this is the answer that was given to me. I'll be quoting the answer as it was and give credit to the one who answere it.
XAMPP is very proud that it don't have to set any environment
variables or registry values.
What you want to do is not possible with XAMPP portable without
mapping to a specific Drive letter. All configurations in xampp
portable have relative paths, so if you want to use cli from a
different drive letter, php can be executed, but all extensions of
them throw errors.
I would install the full version of XAMPP, map it to the current drive
letter with help of the setup_xampp.bat file and use the XAMPP control
panel Shell instead of default command line (advantage: The XAMPP
control panel shell sets local include paths to the needed XAMPP
folders).
Works for me (i can even use pear, git, composer, and other cli
scripts with the Xampp Shell if correct integrated).
best wishes, Altrea
credits to Altrea
Open your php.ini file, replace all relative paths to absolute paths. Eg: \xampp\ to C:\xampp\

How can I create a portable perl when I can't install modules on the target host?

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.