http://www.perlmonks.org?node_id=1141722


in reply to Re^3: Net-SSH2 on Windows with Perl 5.14
in thread Net-SSH2 on Windows with Perl 5.14

I did not know that there are instructions on the distribution itself, i.e. ActiveState Perl?!

I only know about the BUILDING.WIN32 in the github repo (https://github.com/rkitover/net-ssh2), which, when following, end up in a perl 5.8.8 under MinGW ...

Do you have a pointer for me of the ActiveState instructions?

  • Comment on Re^4: Net-SSH2 on Windows with Perl 5.14

Replies are listed 'Best First'.
Re^5: Net-SSH2 on Windows with Perl 5.14
by Anonymous Monk on Sep 12, 2015 at 00:09 UTC

    I did not know that there are instructions on the distribution itself, i.e. ActiveState Perl?! I only know about the BUILDING.WIN32 in the github repo (https://github.com/rkitover/net-ssh2), which, when following, end up in a perl 5.8.8 under MinGW ... Do you have a pointer for me of the ActiveState instructions?

    Its the same file :) why do you want to compile everything from source? Most of the time that is just a hassle, so you go to looking for binaries from the devs/maintainers so you only have to compile the perl side of things

    Easiest path (since strawberryperl folks already compiled the prerequisites)

    Go to http://strawberryperl.com/releases.html and get a portablezip edition, unzip it, then

    run "portableshell.bat"

    download/unzip Net-SSH2... then chdir to that directory in the portableshell window

    Then edit Makefile.PL essentially as per https://github.com/rkitover/net-ssh2/blob/master/BUILDING.WIN32 , set basic http://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html

    $ENV{LIBRARY_PATH}='strawberry-perl-5.22.0.1-64bit-portable/c/lib'; $ENV{C_INCLUDE_PATH}='strawberry-perl-5.22.0.1-64bit-portable/c/includ +e';

    so gcc... knows how to find libssh2.h/libssh2.a

    Then run ....fullpathtoactivestate\bin\perl.exe Makefile.PL

    The whole trick of it most of the time is simple "%PATH%" manipulation

    Post details if you get stuck

    links like these talk about it or link to links that talk about it... most of it is "sh configure ... make" or "perl Makefile.PL... make" ... A Guide To Installing Modules...copy/paste

      Thanks to your instructions, I managed to successfully build NetSSH2 for 5.16 and also for 5.14, each in 32 Bit.

      I stick to the 32 bit version, because I had problems with method scp_get in the past returning only an empty file, even using the pre-compiled binaries 0.53.

      What I did in short:

      • Downloaded Strawberry-Perl Portable 32bit 5.14
      • Extracted to c:\strawberry, opened cmd.exe and called portableshell.bat
      • Downloaded the alpha version of Net::SSH2 (0.54_02), extracted somewhere else and cd'd into that dir
      • Set lib/include paths for gcc, as recommended by you
        set LIBRARY_PATH=c:\strawberry\c\lib
        set C_INCLUDE_PATH=c:\strawberry\c\include
      • c:\perl\bin\perl.exe Makefile.PL (this is my ActiveState installation)
      • dmake (in order to build it)

      I did not test the libraries yet, but I'd expect that it'll be ok...

      But I did not manage to build it for perl versions above perl 5.16:
      I looks to me that there are two different versions, one with 64 bit integers and one without. No matter which version I try, every time I get pages of this kind of error:

      SSH2.c:1103:14: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] ss = (SSH2 *)SvIV((SV*)SvRV(ST(0))); ^

      Sometimes I get even this error:

      SSH2.o:SSH2.c:(.text+0x14f8d): undefined reference to `CRYPTO_set_dyn lock_destroy_callback' C:/STRAWB~1/c/bin/../lib/gcc/i686-w64-mingw32/4.8.3/../../../../i686- w64-mingw32/bin/ld.exe: SSH2.o: bad reloc address 0x1768 in section `.rdata' C:/STRAWB~1/c/bin/../lib/gcc/i686-w64-mingw32/4.8.3/../../../../i686- w64-mingw32/bin/ld.exe: final link failed: Invalid operation collect2.exe: error: ld returned 1 exit status dmake: Error code 129, while making 'blib\arch\auto\Net\SSH2\SSH2.dl l'

      Before your advice, I did not try to use a strawberry perl because I thought that strawberry is compiled with gcc, whereas ActivePerl used Microsoft compilers. But this has turned out to be WRONG! Both use gcc.

      I will continue to test the perls 5.18 and above and also 64 bit versions. Right now, I am able to test the new version of Net::SSH2.

      Thanks for your wisdom!
      Bogi

        SSH2.c:1103:14: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]

        This is a fairly common warning with perls where perl -V:ivsize and perl -V:ptrsize output different values, but it shouldn't arise when the 2 values are the same.
        (Eg, it shouldn't arise on 32-bit perls built with 32-bit integers.)

        SSH2.o:SSH2.c:(.text+0x14f8d): undefined reference to `CRYPTO_set_dynlock_destroy_callback'

        You said that this happens "sometimes", but hopefully it's not random.
        It looks like a problem with the linking command - perhaps a missing or mis-located -leay32.
        (With the Strawberry Perl distro, the symbol is defined in libeay32.a.)

        What are the conditions that determine whether or not you get that error ?

        whereas ActivePerl used Microsoft compilers. But this has turned out to be WRONG! Both use gcc.

        Prior to perl-5.18.0, ActivePerl was built using Microsoft's MSVC 6.0 compiler - but since then they've been building with gcc.
        However, even with the MSVC-built perls (since about perl-5.10.0), it has been straightforward to use gcc with ActivePerl.

        Cheers,
        Rob

        Sometimes I get even this error: perl SSH2.c undefined reference to CRYPTO_set_dynlock_destroy_callback

        That is usually a matter of arranging -Ldirpath -llibname ... either one is missing from the list (one that provides the symbol CRYPTO_set_dynlock_destroy_callback )

        or its in the wrong order , -lcrypto needs to come before -lsomethingelse

        or there are two -lcryptos, an old one and a new one, and its finding the old one first, so adjust the -Lpath

        Unless you're the developer, its usually a little bit of trial and error to figure it out

        and if that fails you contact the developer :)

         SSH2.c:1103:14: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]          ss = (SSH2 *)SvIV((SV*)SvRV(ST(0)));

        These can be a little trickier :) maybe a missing #define DOTHE64BITVERSION (or via a flag -DDOTHE64BITVERSION ) ... nothing jumps out at me from Net-SSH2 :)

        Or its simply an oversight by the developer :) its hard to predict all combinations of everything

        So drop a copy of the full cli session to the devs, rt://Net-SSH2

        Before your advice, I did not try to use a strawberry perl because I thought that strawberry is compiled with gcc, whereas ActivePerl used Microsoft compilers. But this has turned out to be WRONG! Both use gcc.

        :) I haven't checked in a while, but ActivePerl actually uses the microsoft compiler to compile their product, but they also provide MinGW/gcc via ppm, so you can compile other modules ... compilers, they're compatible with each other ... and with perl (as long as you "patch" Config to act appropriately, which ActivePerl does (someway), but in general Re^4: Advantages of Activeperl vs Strawberry Perl, Compiling C/C++ based Modules under ActiveState using MinGW)

        links here like activestate.com/blog... How to install CPAN modules into ActivePerl