Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved SFtp Client with LIBSSH

    General and Desktop
    4
    11
    3553
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ODБOï
      ODБOï last edited by

      Hello,

      I'm trying to create SFtp client using Libssh (with Qt5.10 mingw53_32)

      I have installed libssh-0.7.2-mingw.exe from here : https://red.libssh.org/projects/libssh/files

      then i have copied all the headers + libssh.dll and libssh.dll.a to my Qt project.

      and also added this to my .pro

      LIBS += -L$$PWD/./ -llibssh.dll 
      INCLUDEPATH += $$PWD/.
      DEPENDPATH += $$PWD/.
      

      Now in my main.cpp i'm including libssh : #include "libssh.h" and trying to create session

       ssh_session my_ssh_session = ssh_new();
      

      It compiles witout errors but craches as soon as i hit RUN button in Qt Creator

      Can please someone tell me what im doing wrong ?

      Thank you in advance
      LA

      jsulm 1 Reply Last reply Reply Quote 1
      • jsulm
        jsulm Lifetime Qt Champion @ODБOï last edited by

        @LeLev Please start your app in debug mode (F5) and see where exactly it crashes (you can post stack trace here).
        Most probably the DLLs are not in the same directory where your exe is - you can copy them to this directory and start again.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 3
        • aha_1980
          aha_1980 Lifetime Qt Champion last edited by

          @LeLev said in SFtp Client with LIBSSH:

          LIBS += -L$$PWD/./ -llibssh.dll

          Looks odd. Try changing this line to:

          LIBS += -L$$PWD -lssh

          Creator scans your LIBS lines and adds them to the DLL search path, so in principle it should work out of the box.

          Qt has to stay free or it will die.

          1 Reply Last reply Reply Quote 2
          • ODБOï
            ODБOï last edited by

            @jsulm i have copied libssh.dll near the .exe, and when i run in debug mode i have :

            During startup program exited with code 0xc0000135

            As @aha_1980 suggested i replaced LIBS += -L$$PWD/./ -llibssh.dll by LIBS += -L$$PWD -lssh but it still craches.

            Thx for help

            jsulm 1 Reply Last reply Reply Quote 1
            • jsulm
              jsulm Lifetime Qt Champion @ODБOï last edited by jsulm

              @LeLev Probably more DLLs are missing. You can use http://www.dependencywalker.com/ to check what is missing.
              Another reason could be that a different version of MinGW was used.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply Reply Quote 2
              • ODБOï
                ODБOï last edited by

                In fact, auther dlls are missing. I have deployed my application and just double clicked .exe (not from qt creator) now i have more "readable" error : missing zlib1.dll

                after adding that dll, it is working !

                Thank you very much @jsulm and @aha_1980

                1 Reply Last reply Reply Quote 3
                • ODБOï
                  ODБOï last edited by

                  Im back here because it looks like everything is working fine but this line is making my app crash

                   sftp = sftp_new(my_ssh_session); //  Crash here : Segmentation fault 
                  
                  ssh_session my_ssh_session = ssh_new();
                      if (my_ssh_session == NULL)
                        qDebug("error ssh session creation");//exit(-1);
                  sftp_session sftp;
                  sftp = sftp_new(my_ssh_session); //  Crash here : Segmentation fault 
                      if(sftp==NULL)
                        qDebug("error sftp session creation");
                  
                  1 Reply Last reply Reply Quote 0
                  • SGaist
                    SGaist Lifetime Qt Champion last edited by

                    Hi,

                    Since there's a crash you should post the stack trace.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    ODБOï 1 Reply Last reply Reply Quote 0
                    • ODБOï
                      ODБOï @SGaist last edited by

                      @SGaist hello,

                      When im debuging step by step, my program crashes here :

                      sftp = sftp_new(my_ssh_session); // Crash here : Segmentation fault

                      and qt creator switches to : Disassembler (ssh_socket_write)

                      0x61ae40bf  <+0x008f>        0f 84 5f 01 00 00              je     0x61ae4224 <ssh_socket_write+500>
                      0x61ae40c5  <+0x0095>        8b 50 0c                       mov    0xc(%eax),%edx  // error here ..
                      0x61ae40c8  <+0x0098>        85 d2                          test   %edx,%edx
                      0x61ae40ca  <+0x009a>        0f 84 54 01 00 00              je     0x61ae4224 <ssh_socket_write+500>
                      
                      1 Reply Last reply Reply Quote 0
                      • SGaist
                        SGaist Lifetime Qt Champion last edited by

                        Looks like you are trying to debug a release version of your app.

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        ODБOï 1 Reply Last reply Reply Quote 2
                        • ODБOï
                          ODБOï @SGaist last edited by

                          @SGaist my bad
                          Thx

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post