Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
SFtp Client with LIBSSH
-
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
-
@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.
-
@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.
-
@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.dllby LIBS += -L$$PWD -lssh but it still craches.Thx for help
-
@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.
-
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 !
-
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");
-
Hi,
Since there's a crash you should post the stack trace.
-
@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>
-
Looks like you are trying to debug a release version of your app.
-
@SGaist my bad
Thx