Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. SFtp Client with LIBSSH
Forum Update on Monday, May 27th 2025

SFtp Client with LIBSSH

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 4 Posters 4.3k Views
  • 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ïO ODБOï

    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

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #2

    @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
    3
    • aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #3

      @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
      2
      • ODБOïO Offline
        ODБOïO Offline
        ODБOï
        wrote on last edited by
        #4

        @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

        jsulmJ 1 Reply Last reply
        1
        • ODБOïO ODБOï

          @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

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by jsulm
          #5

          @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
          2
          • ODБOïO Offline
            ODБOïO Offline
            ODБOï
            wrote on last edited by
            #6

            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
            3
            • ODБOïO Offline
              ODБOïO Offline
              ODБOï
              wrote on last edited by
              #7

              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
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #8

                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ïO 1 Reply Last reply
                0
                • SGaistS SGaist

                  Hi,

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

                  ODБOïO Offline
                  ODБOïO Offline
                  ODБOï
                  wrote on last edited by
                  #9

                  @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
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    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ïO 1 Reply Last reply
                    2
                    • SGaistS SGaist

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

                      ODБOïO Offline
                      ODБOïO Offline
                      ODБOï
                      wrote on last edited by
                      #11

                      @SGaist my bad
                      Thx

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved