martydavis has asked for the wisdom of the Perl Monks concerning the following question:

I have a working script using Net::SSH2-0.53 that's hunky-dorey in Komodo but when wrapped with PerlApp it can't open a connection. As I understand from ActiveState, the underlying reason is that the .exe uses Windows (8.1) dynamic loading for any dependent libraries and what I really need to do is recompile Net-SSH2. Great.

I have been going mental compiling. I have followed the procedure laid out in the module for windows. I have built zlib-1.2.8, openssl-1.0.1l, and finally libssh2-1.4.3 successfully but when I run perl Mahefile.PL and dmake, I run into problems (below). Any suggestions will be highly valued.

D:\Net-SSH\Net-SSH2-0.53>perl Makefile.PL lib=d:\Net-SSH\libssh2-1.4.3 +\src\.libs inc=d:\Net-SSH\libssh2-1.4.3\include Set up gcc environment - 4.8.1 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 li +ne 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, wh +ich can be obtained from http://www.openssl.org , or libgcrypt, which can be o +btained 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) o +n 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 paramet +er to Makefile.PL, e.g.: perl Makefile.PL gcrypt If you want to build on Windows, see the file BUILDING.WIN32 in the distribution. Warning (mostly harmless): No library found for -lssl32 Warning (mostly harmless): No library found for -leay32 Generating a dmake-style Makefile Writing Makefile for Net::SSH2 Writing MYMETA.yml and MYMETA.json D:\Net-SSH\Net-SSH2-0.53>dmake Skip blib\lib\Net\SSH2\File.pm (unchanged) Skip blib\lib\Net\SSH2\PublicKey.pm (unchanged) Skip blib\lib\Net\SSH2\Dir.pm (unchanged) Skip blib\lib\Net\SSH2\SFTP.pm (unchanged) Skip blib\lib\Net\SSH2\Listener.pm (unchanged) Skip blib\lib\Net\SSH2\Channel.pm (unchanged) Skip blib\lib\Net\SSH2.pm (unchanged) Running Mkbootstrap for Net::SSH2 () "C:\perl\bin\perl.exe" "-Iinc" -MExtUtils::Command -e chmod -- 644 "SS +H2.bs" c:\mingw\bin\gcc.exe -c -Id:\Net-SSH\libssh2-1.4.3\include -I. + -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -DPERL_TEXTMODE_SCRIPTS -DUSE_SITECUST +OMIZE -DPE RL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D_USE_32BIT_TIME +_T -DHASAT TRIBUTE -fno-strict-aliasing -mms-bitfields -O2 -DVERSION=\" +0.53\" -DXS_VERSION=\"0.53\" "-IC:\Perl\lib\CORE" -DLIBSSH2_WIN32 -DLIBSSH2 +_API= SSH2 .c In file included from C:\Perl\lib\CORE/win32thread.h:4:0, from C:\Perl\lib\CORE/perl.h:2834, from SSH2.xs:8: C:\Perl\lib\CORE/win32.h:297:13: error: conflicting types for 'mkstemp +' extern int mkstemp(const char *path); ^ In file included from C:\Perl\lib\CORE/perl.h:681:0, from SSH2.xs:8: c:\mingw\include\stdlib.h:610:29: note: previous definition of 'mkstem +p' was her e int __cdecl __MINGW_NOTHROW mkstemp( char *__filename_template ) ^ dmake.exe: Error code 129, while making 'SSH2.o' D:\Net-SSH\Net-SSH2-0.53>

Replies are listed 'Best First'.
Re: Making Net::SSH2
by syphilis (Archbishop) on Feb 10, 2015 at 04:15 UTC
    Hi,

    As I understand from ActiveState, the underlying reason is that the .exe uses Windows (8.1) dynamic loading for any dependent libraries.

    I have no idea whether that's correct.
    A bit more info on what's happening there might help.

    You could also try:
    ppm install http://www.sisyphusion.tk/ppm/Net-SSH2.ppd --force

    That should install a Net-SSH2-0.53 that was built against static libs. It also installs a couple of dll's that need to be loaded at runtime, and it might be that those 2 dll's need to be explicitly loaded into the app. (You should find them in your $Config{sitebin}.)

    As to the actual error that's killing your build it seems that both your perl and your mingw have decided to independently prototype a function named "mkstemp".
    None of my mingw versions of stdlib.h contain such a function, but your mingw stdlib.h apparently does. (I don't have a mingw.org build of 4.8.1.)

    I don't know how one is supposed to correctly deal with this, but both versions take a char* arg and return an int.
    I would therefore try commenting out the prototype in either stdlib.h or win32.h, then run 'dmake', and then reinstate the removed the prototype after the build has finished.

    This is a problem that should arise for every perl extension that you attempt to build, and has nothing particularly to do with Net::SSH2.

    Cheers,
    Rob

      Ever so grateful for your suggestions. I tried the statically compiled version with ppm as well as editing stdlib.h. The ppm method worked fine up to using the wrapped exe - same problem. The script runs fine but dies on connect. (works fine in Komodo!) Also, your suggestion fixed the dmake error but, alas, same problem with the PerlApp exe. Maybe static recompiling isn't the solution here. Any other ideas?

        The script runs fine but dies on connect.

        The error messages might be useful - depending upon what they are (if they exist ;-)

        If you're not getting any useful error messages && you're building libssh2 by running Configure in the msys shell, it might be helpful to have a debug build of the library - which you can get by providing the --enable-debug option to Configure.

        Cheers,
        Rob