如何在Cygwin上从CPAN安装Net :: SSH2

时间:2014-12-11 11:47:25

标签: windows perl cygwin cpan openssh

我需要在Windows 7(64位)下的Cygwin环境中安装Net:SSH2。通常我尝试使用cpanm安装它。

我已经安装了必要的Cygwin软件包(见下文),但是Perl构建失败了,因为它找不到libssh2库。

Net::SSH2包中有一个特殊的文本文件BUILDING.WIN32,但这仅在手动构建模块时有用,主要指MinGW。所以这没有用。

这是构建的日志:

Entering Net-SSH2-0.53
Checking configure dependencies from META.yml
Checking if you have ExtUtils::MakeMaker 6.59 ... Yes (7.02)
Running Makefile.PL
Configuring Net-SSH2-0.53 ... 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 (and extra link args) on the
command line. E.g.:

    perl Makefile.PL lib=$HOME/libssh2/lib inc=$HOME/libssh2/include \
        ldargs="-lz"

These can also be set through the LIBSSH2_LIB/LIBSSH2_INCLUDE/LIBSSH2_LDARGS
environment variables.

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.

Can't link/include C library 'ssh2', aborting.

1 个答案:

答案 0 :(得分:0)

首先安装Cygwin的libssh2-devel包,例如使用apt-cyg命令行前端从cygwin shell中安装软件包。

apt-cyg install libssh2-devel

然后将一些环境变量设置到正确的路径以使Net::SSH2与Cygwin包一起使用:

LIBSSH2_LIB=/usr/lib/ LIBSSH2_INCLUDE=/usr/include/ cpanm -v Net::SSH2

这对我有用。比上面链接的自述文件看起来容易得多。