net-ssh2 installation in linux - perl

I am trying to install Net-SSH2 in linux server and it is asking for lots of dependencies.
I installed both libssh2 and openssl, but still it throws the follwoing error.
/opt/script/Net-SSH2-0.52/assertlibcssKKx3q: error while loading shared libraries: libssh2.so.1: cannot open shared object file: No such file or directory
wrong result: 'ssh2'
Can someone tell me whats happening here?
Please find below the installation log
[root#vm Net-SSH2-0.52]# perl Makefile.PL
Subroutine checklibs redefined at inc/Module/Install/CheckLib.pm line 11.
Subroutine assertlibs redefined at inc/Module/Install/CheckLib.pm line 25.
Subroutine _author_side redefined at inc/Module/Install/CheckLib.pm line 39.
The libssh2 library is required by this module. If you don't have it, you can
download it from http://www.libssh2.org; you may also need OpenSSL, which can be
obtained from http://www.openssl.org, or libgcrypt, which can be obtained from
http://www.gnupg.org.
Debian: sudo aptitude install libssh2-1-dev
OpenSUSE: sudo zypper in libssh2-1 libssh2-devel
You can pass your libssh2 lib and include dirs on the command line. E.g.:
perl Makefile.PL lib=$HOME/libssh2/lib inc=$HOME/libssh2/include
To build with libgcrypt instead of OpenSSL, pass 'gcrypt' as a parameter to
Makefile.PL, e.g.:
perl Makefile.PL gcrypt
If you want to build on Windows, see the file BUILDING.WIN32 in the
distribution.
/opt/leo/perlscript/Net-SSH2-0.52/assertlibjmyXurmJ: error while loading shared libraries: libssh2.so.1: cannot open shared object file: No such file or directory
wrong result: 'ssh2'

Related

perl DBI module installation erroring out

perl DBI module installation is erroring out.
Installed perl 5.32.1 in non standard location, using -Dinstallprefix option
./Configure -Dinstallprefix=/test/user/home/perl -des
make
make test
make install
/test/user/home/perl/bin/perl -version
This is perl 5, version 32, subversion 1 (v5.32.1) built for x86_64-linux
Set PERL5LIB env variable
export PERL5LIB="/test/user/home/perl/lib/5.32.1:/test/user/home/perl/lib/site_perl/5.32.1:/test/user/home/perl/lib/5.32.1/x86_64-linux"
which perl
/test/user/home/perl/bin/perl
Downloaded DBI-1.643 archive, after extraction execution of Makefile.PL is failing
perl Makefile.PL
Warning: PERL_LIB (/perl/lib/5.32.1) seems not to be a perl library directory
(strict.pm not found) at /test/user/home/perl/lib/5.32.1/ExtUtils/MM_Unix.pm line 1934.
Have /test/user/home/perl/lib/5.32.1/x86_64-linux
Want /perl/lib/5.32.1/x86_64-linux
Your perl and your Config.pm seem to have different ideas about the
architecture they are running on.
Perl thinks: [x86_64-linux]
Config says: [x86_64-linux]
This may or may not cause problems. Please check your installation of perl
if you have problems building this extension.
Can't stat /perl/lib/5.32.1: No such file or directory
at Makefile.PL line 280.
Can't stat /perl/lib/5.32.1/x86_64-linux: No such file or directory
at Makefile.PL line 280.
Failed to opendir '/perl/lib/5.32.1/x86_64-linux/CORE' to find header files: No such file or directory at /test/user/home/perl/lib/5.32.1/ExtUtils/MM_Any.pm line 3048.
Found non existing paths are referred from #INC
perl -e "print \"#INC\""
/test/user/home/perl/lib/5.32.1 /test/user/home/perl/lib/site_perl/5.32.1 /test/user/home/perl/lib/5.32.1/x86_64-linux
/perl/lib/site_perl/5.32.1/x86_64-linux /perl/lib/site_perl/5.32.1 /perl/lib/5.32.1/x86_64-linux /perl/lib/5.32.1
Can someone guide me where from #INC getting these non existing paths
/perl/lib/site_perl/5.32.1/x86_64-linux /perl/lib/site_perl/5.32.1 /perl/lib/5.32.1/x86_64-linux /perl/lib/5.32.1
are there any way to restrict #INC to append non existing paths?
I think you want just -Dprefix=/.... There are other things that need to end up in the right place too. You shouldn't need to set PERL5LIB though because perl should be using your prefix as its default #INC. What does your perl -V show?
There is an installprefix, but it's aimed at compiling on one machine and installing on another. However, the INSTALL docs also recommend against using that. Is that what you are trying to do?
As for the other directories, the INSTALL docs describe the various directories that show up in #INC.
Thank you #brian for pointing me in right direction.
Following was the root cause behind #INC contains non existing directories.
Last time during perl installation at least one time I ran following command
./Configure -des -Dprefix=/perl
Use relocatable #INC? [n]
Pathname where the private library files will reside? (~name ok)
[/perl/lib/5.32.1]
Where do you want to put the public architecture-dependent libraries? (~name ok)
[/perl/lib/5.32.1/x86_64-linux]
Pathname for the site-specific library files? (~name ok)
[/perl/lib/site_perl/5.32.1]
Pathname for the site-specific architecture-dependent library files? (~name ok)
[/perl/lib/site_perl/5.32.1/x86_64-linux]
then executed make command. Later on make test failed for other error.
Then without running make distclean command, I re ran Configure with
-Dinstallprefix option
./Configure -Dinstallprefix=/test/user/home/perl -des
This populate #INC as follows
/test/user/home/perl/lib/5.32.1 /test/user/home/perl/lib/site_perl/5.32.1 /test/user/home/perl/lib/5.32.1/x86_64-linux
/perl/lib/site_perl/5.32.1/x86_64-linux /perl/lib/site_perl/5.32.1 /perl/lib/5.32.1/x86_64-linux /perl/lib/5.32.1
To fix this issue executed following steps,
make distclean
./Configure -des -Dprefix=/test/user/home/perl -Dusethreads
now #INC is populated correct
#INC:
/test/user/home/perl/lib/site_perl/5.32.1/x86_64-linux-thread-multi
/test/user/home/perl/lib/site_perl/5.32.1
/test/user/home/perl/lib/5.32.1/x86_64-linux-thread-multi
/test/user/home/perl/lib/5.32.1
Now DBI installation ran successfully.

Installing cURL modules for Perl on Windows

I have ActivePerl 5.14.2 on my Windows machine. I have been trying to install the LWP cURL module. I have already installed the libcurl-dev library and GCC on my machine.
I also understand that LWP cURL has a dependency on the WWW-Curl-Easy module. So I installed that too. I installed all these through the command lines using the steps given in the Readme files. I ran the perl makefile.pl command followed by a make and a make install. No errors were given out during the installation.
I am trying to execute this sample code to test my LWP cURL installation:
use LWP::Curl;
use strict;
use warnings;
my $lwpcurl = LWP::Curl->new();
my $content = $lwpcurl->get('http://search.cpan.org','http://www.cpan.org');
I am receiving the below error:
Can't locate loadable object for module WWW::Curl in #INC (#INC
contains: C:/Perl64/site/lib C:/Perl64/lib .) at
C:/Perl64/site/lib/WWW/Curl.pm line 11. BEGIN failed--compilation
aborted at C:/Perl64/site/lib/WWW/Curl.pm line 11. Compilation failed
in require at C:/Perl64/site/lib/WWW/Curl/Easy.pm line 9. Compilation
failed in require at C:/Perl64/site/lib/LWP/Curl.pm line 5. BEGIN
failed--compilation aborted at C:/Perl64/site/lib/LWP/Curl.pm line 5.
Compilation failed in require at D:\Varsha\Curl.pl line 1. BEGIN
failed--compilation aborted at D:\Varsha\Curl.pl line 1.
Where am I going wrong?
This is probably not the direction you want to go, but I'd advise you to consider upgrading your perl and changing distributions:
Install Strawberry Perl - 5.18.2.2 is the currently recommended version.
Install cpanm: perl -MCPAN -e "install App::cpanminus"
Install LWP::Curl: cpanm LWP::Curl
I won't bother trying convince you of the change, but Strawberry Perl and cpanm in combination make installing modules a lot easier than having to dealing with the proprietary ppm's of ActivePerl in my opinion.
Just something to consider if you ever get tired of the occasional headaches.
The error means that WWW::Curl is either not installed or its path is not searchable (it's not in #INC). So the solutions are
Make sure that the module is installed.
Add the path where the module is installed to the #INC. Since you are on Windows, you can use set PERL5LIB = c:\path\to\dir
For a permanent solution follow the below:
Right-click My Computer and click Properties.
In the System Properties window, click on the Advanced tab.
In the Advanced section, click the Environment Variables button.
In the Environment Variables window in the "User variables for Foo Bar" section click on New and type in the following:
Variable name: PERL5LIB
Variable value: c:\path\to\dir
Then click OK 3 times. Windows that you open after this will already know about the new variable. Type this in the command window, to see the newly set value:
echo %PERL5LIB%
This will add the private /home/foobar/code directory (or c:\path\to\dir directory) to the beginning of #INC for every script that is executed in the same environment.
Also see: Installing perl dependency automatically in perl

Jquery File Upload using cgi

I am new to perl scripting.I am working on drag and drop file upload and using jquery file upload.I'll appreciate if you can help me in installing this perl module and how to use it.
I am trying to follow readme file but while doing "Perl Makefile.pl" some warnings are there
Warning: prerequisite Image::Magick 0 not found.
Warning: prerequisite JSON::XS 0 not found.
Warning: prerequisite Net::SSH2 0 not found.
Warning: prerequisite Net::SSH2::SFTP 0 not found.
WARNING: Setting ABSTRACT via file 'lib/jQuery/File/Upload.pm' failed
at /usr/lib/perl5/5.8.8/ExtUtils/MakeMaker.pm line 609
Writing Makefile for jQuery::File::Upload
Writing MYMETA.yml and MYMETA.json
i am not sure if it is installed or not.
Please help me for implementation.
Thanks,
Manish
It failed or you will likely gets problems anyway, and you will likely need to install the packages mentioned in the errors. You may also need to install some ssl dev lib bits. For example on mine (Linux Mint/Ubuntu), I needed to do the following...
#edit, looks like on yours you need to install Image::Magick as well
sudo cpan JSON::XS
sudo apt-get install libssh2-1-dev
sudo apt-get install libssl-dev
sudo cpan Net::SSH2
Note: the above packages you may want to see if you can find via your package manager rather than CPAN, however the above should steer you in the right direction of the things you probably need.
then back to the README
perl Makefile.PL
make
make test
make install

Using XPath with Perl

I am trying to replicate what my C#/XPath code does on Linux using Perl. I copied and pasted the code in Example 8-6 in Perl & XML. If I understand right, I should be able to run that Perl code, put this code in terminal
xmlPerl.pl mydatafile.xml "/inventory/category/item/name"
But when I try to run the Perl file, it doesn't work. Here is the error:
[root#Perl ~]# perl xmlPerl.pl
Can't locate XML/XPath.pm in #INC (#INC contains: /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.7/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.6/x86_64-linux-thread-multi /usr/lib64/perl5/site_perl/5.8.5/x86_64-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.7 /usr/lib/perl5/site_perl/5.8.6 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.7/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.6/x86_64-linux-thread-multi /usr/lib64/perl5/vendor_perl/5.8.5/x86_64-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/5.8.7 /usr/lib/perl5/vendor_perl/5.8.6 /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8 .) at xmlPerl.pl line 3.
BEGIN failed--compilation aborted at xmlPerl.pl line 3.
What am I doing wrong? I think it has something to do with the XML and XPath names in the beginning of my code. Do I need to install something to use the XPath framework? I am running on RedHat 5.5.
From perldiag:
Can't locate %s
You said to do (or require, or use) a file that couldn't be found. Perl looks for the file in all the locations mentioned in #INC, unless the file name included the full path to the file. Perhaps you need to set the PERL5LIB or PERL5OPT environment variable to say where the extra library is, or maybe the script needs to add the library name to #INC. Or maybe you just misspelled the name of the file. See require in perlfunc and lib.
You don't have installed XML::XPath module, or Perl not found it. Install module with CPAN:
> cpan XML::XPath
or with package manager:
> apt-get install libxml-xpath-perl
Or if it already installed say where it is with PERL5LIB environment variable:
> PERL5LIB=/path/to/lib perl ...
#INC variable:
BEGIN {
unshift(#INC, '/path/to/lib');
}
or lib pragma:
use lib '/path/to/lib';
That's the standard error that comes from trying to use a module that isn't installed. You should install it.
Ideally use the OS package for it; for example on a debian-derived OS (such as Debian or Ubuntu)
$ apt-get install libxml-xpath-perl
Failing that, you can install it as usual using CPAN
$ cpan XML::XPath
The answer is in the first part of your error:
Can't locate XML/XPath.pm
In Perl, the huge benefit is from using modules, or libraries, that others have written for you and you can reuse. In this case, someone has written a module called XML::XPath (in Perl, the path is delineated by '::') and you just need to install it. The easiest way to install it is via cpan, it's a tool that comes installed with most Perl installations. Just run:
cpan
(you'll be dropped into a different command prompt)
install XML::XPath
This will go out and fetch XML::XPath, unpack it, generate the Makefile, check for dependencies (and install any that are missing), make it, test it, and install it for you. Look here for more information on using CPAN.

Why can't DynaLoader.pm load SSleay.dll for Net::SSLeay and Crypt::SSLeay?

I have Perl v5.10. I am trying to install Net::SSLeay 1.30 and Crypt::SSLeay 0.57.
I have already installed OpenSSL 0.9.8e.
For Net::SSLeay 1.30 I followed these steps:
perl Makefile.PL -windows C:\openssl
nmake
nmake test -- test fails
nmake install
perl test.pl
but I got an fatal error as:
D:\perl\Net_SSLeay.pm-1.30>perl -w test.pl
1..20
Can't load 'D:/perl/site/lib/auto/Net/SSLeay/SSLeay.dll' for module Net::SSLeay: load_file:The specified module could not be found at D:/perl/lib/DynaLoader.pm line 203.
at test.pl line 25
Compilation failed in require at test.pl line 25.
BEGIN failed--compilation aborted at test.pl line 25.
I got the same results for Crypt::SSLeay 0.57.
Randy Kobes has an answer for this on the Perl Win32 mailing list. Does your PATH environment variable contain the directory that contains libeay32.dll or ssleay32.dll?
There are many other answers that you can find in Google too. In cases like these, I take the whole error message and shove it into the Google search bar. I start cutting out parts of the error message, such as the specific paths, until I get some search results. This almost always works for me since I'm rarely the first person to have a problem.
Shared libs often have external dependencies, and on some operating systems those dependencies need to be immediately fulfilled when the first shared library is loaded, like your SSLeay.dll, which usually needs the two crypto libs. On linux you can check with ldd the run-time behavior, if all libs are found.
To debug this add the env var PERL_DL_DEBUG=5, like set PERL_DL_DEBUG=5 and try again or use the external tool depends.exe to see what dll's exactly are missing.
I had a similar problem with Windows Par::Packer. The resulting myprogram.exe had trouble loading rurban's hint with PERL_DL_DEBUG
Can't load 'temp\7e717f68.xs.dll' for module Crypt::SSLeay: load_file:Das angegebene Modul wurde nicht gefunden at <embedded>/DynaLoader.pm line 193.
at <embedded>/PAR/Heavy.pm line 95.
I was not able to find out which dlls to include with pp. After these hints I was simply looking to the dll-file with a hex editor and found this string: libgcc_s_dw2-1.dll - this was the dll to include into my "compiled" exe-program:
pp -M Crypt::SSLeay ^
-l c:/strawberry/perl/vendor/lib/auto/Crypt/SSLeay/SSLeay.xs.dll ^
-l c:/strawberry/c/bin/libgcc_s_dw2-1.dll ....
I'm having this same problem with a fresh install of Strawberry Perl 5.30. Googling the error just gives a bunch of unanswered, or half answered questions. Rurban is pointing in the right direction with using depends.exe. Opening ssleay.xs.dll and waiting for it to finishing throwing errors shows 5 main dll's that it depends on. 2 of which are windows core dll's, and 3 from openssl and perl. In the strawberry install, the 2 dll's related to crypto are in the [perlinstallpath]\c\bin folder. Add this to your windows %PATH% variable and it will start working.