1

I am trying to install Net:SSH2 Perl module, but I run in this error:

[root@script-server fmzbih_cms_weather_updater]# cpanm Net::SSH2
--> Working on Net::SSH2
Fetching http://www.cpan.org/authors/id/R/RK/RKITOVER/Net-SSH2-0.44.tar.gz ... OK
Configuring Net-SSH2-0.44 ... OK
Building and testing Net-SSH2-0.44 ... FAIL
! Installing Net::SSH2 failed. See /root/.cpanm/build.log for details.
[root@script-server fmzbih_cms_weather_updater]# cat /root/.cpanm/build.log
cpanm (App::cpanminus) 1.5011 on perl 5.014002 built for i686-linux-thread-multi
Work directory is /root/.cpanm/work/1335442976.25013
You have make /usr/bin/make
You have LWP 6.04
You have /bin/tar: tar (GNU tar) 1.15.1
You have /usr/bin/unzip
Searching Net::SSH2 on cpanmetadb ...
--> Working on Net::SSH2
Fetching http://www.cpan.org/authors/id/R/RK/RKITOVER/Net-SSH2-0.44.tar.gz
-> OK
Unpacking Net-SSH2-0.44.tar.gz
Entering Net-SSH2-0.44
Checking configure dependencies from META.yml
Checking if you have ExtUtils::MakeMaker 6.59 ... Yes (6.62)
Configuring Net-SSH2-0.44
Running 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.

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

If you want to build on Windows, see the file BUILDING.WIN32 in the
distribution.

Checking if your kit is complete...
Looks good
Writing Makefile for Net::SSH2
Writing MYMETA.yml and MYMETA.json
-> OK
Checking dependencies from MYMETA.json ...
Checking if you have ExtUtils::MakeMaker 6.59 ... Yes (6.62)
Building and testing Net-SSH2-0.44
cp lib/Net/SSH2/File.pm blib/lib/Net/SSH2/File.pm
cp lib/Net/SSH2/Dir.pm blib/lib/Net/SSH2/Dir.pm
cp lib/Net/SSH2/PublicKey.pm blib/lib/Net/SSH2/PublicKey.pm
cp lib/Net/SSH2/SFTP.pm blib/lib/Net/SSH2/SFTP.pm
cp lib/Net/SSH2/Listener.pm blib/lib/Net/SSH2/Listener.pm
cp lib/Net/SSH2/Channel.pm blib/lib/Net/SSH2/Channel.pm
cp lib/Net/SSH2.pm blib/lib/Net/SSH2.pm
AutoSplitting blib/lib/Net/SSH2.pm (blib/lib/auto/Net/SSH2)
/usr/local/bin/perl "-Iinc" /usr/local/lib/perl5/5.14.2/ExtUtils/xsubpp  -typemap /usr/local/lib/perl5/5.14.2/ExtUtils/typemap -typemap typemap  SSH2.xs > SSH2.xsc && mv SSH2.xsc SSH2.c
cc -c  -I/usr/local/include -I/usr/include -I. -D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2   -DVERSION=\"0.44\" -DXS_VERSION=\"0.44\" -fPIC "-I/usr/local/lib/perl5/5.14.2/i686-linux-thread-multi/CORE"   SSH2.c
Running Mkbootstrap for Net::SSH2 ()
chmod 644 SSH2.bs
rm -f blib/arch/auto/Net/SSH2/SSH2.so
LD_RUN_PATH="/usr/lib:/lib" cc  -shared -O2 -L/usr/local/lib -fstack-protector SSH2.o  -o blib/arch/auto/Net/SSH2/SSH2.so   \
       -L/root -L/usr/local/lib -L/lib -L/usr/lib -L/usr/local/lib -L/usr/local -L/usr/lib -L/usr -L/opt -L//lib -L/ -lssh2 -lz -lssl -lcrypto      \

/usr/bin/ld: cannot find -lz
collect2: ld returned 1 exit status
make: *** [blib/arch/auto/Net/SSH2/SSH2.so] Error 1
-> FAIL Installing Net::SSH2 failed. See /root/.cpanm/build.log for details.

Seems like I am unable to compile something due to glibc static linking. However, I don't know what's alternative for glibc-static on CentOS 5.

MDMarra
  • 100,183
  • 32
  • 195
  • 326
azec-pdx
  • 205
  • 2
  • 5
  • 9
  • Do you have the required library libssh2-dev? – Khaled Apr 26 '12 at 12:58
  • Hi, I do - i just checked libssh2-devel is there and updated to latest version. – azec-pdx Apr 26 '12 at 13:05
  • 1
    I've edited your pastebin text into your answer and wrapped it in code markup to preserve formatting/linebreaks. Please do this in the future instead of linking to an external site. In a year or more when someone stumbles on this question with the same problem, there's no guarantee that pastbin will still host the output, but if you put it in the question, it's guaranteed to exist as long as the question does. – MDMarra Apr 26 '12 at 13:52

2 Answers2

3

Your system is missing the gzip library development files.

Try

yum install zlib-devel

... that should resolve your issue.

Janne Pikkarainen
  • 31,454
  • 4
  • 56
  • 78
  • I was missing zlib actually, and your answer Sir lead me to the good trail. Thank you! Now I am having "/usr/bin/ld: cannot find -lssl" and I don't know again which lib I am missing, as I used different linux distro before. – azec-pdx Apr 26 '12 at 13:15
  • Your new problem is that you are missing `openssl` and/or `openssl-devel` packages. – Janne Pikkarainen Apr 26 '12 at 13:23
  • True. Thanks again! Got it working but now don't know how to tell Perl to use Net::SSH2 instead of Net::SSH. – azec-pdx Apr 26 '12 at 14:03
0

I do tend to use CPAN over the system package managers for perl modules, because CPAN will recursively download and build required dependencies.

cpan man cpan

Tim
  • 2,997
  • 16
  • 15
  • I am actually using cpan minus (cpanm) to manage all CPAN modules. However, I got stuck when executing "cpanm Net::SSH2". Do you know how can I tell Perl not to use Net::SSH and use Net::SSH2 instead? – azec-pdx Apr 26 '12 at 14:02