Integration of libssh into a Qt project



  • I am doing an application to communicate with an embedded software thanks to the libssh tools.
    But every time I call the lib, I have got a crash of my application. I finally decided to simplify my project at the maximum to see what is the problem by doing a simple console project but it is still crashing. So I finally come to you to see if anyone of you have an idea.

    My OS is Windows 7 Professional
    I am developing with QtCreator 3.2.1
    My Qt Version is Qt 5.3.2

    Here is my .pro file:

    TEMPLATE = app
    CONFIG += console
    CONFIG -= app_bundle
    CONFIG -= qt
    
    SOURCES += main.cpp
    
    include(deployment.pri)
    qtcAddDeployment()
    
    LIBS += -L$$PWD/LibSSH/lib -lssh.dll
    
    

    And here is my main.cpp

    #include <iostream>
    #include "LibSSH/include/libssh/libssh.h"
    
    using namespace std;
    
    int main()
    {
       ssh_session my_ssh_session = ssh_new();
       if (my_ssh_session == NULL)
         exit(-1);
    
       ssh_free(my_ssh_session);
    
       cout << "Hello World!" << endl;
       return 0;
    }
    
    

    As you can see, every time I call ssh_new() there is a crash, my console answer me :

    Démarrage de I:\Projets\Test_libssh\release\Test_libssh.exe...
    I:\Projets\Test_libssh\release\Test_libssh.exe s'est terminé avec le code -1073741515
    

    Thanks for your time


  • Moderators

    Did you debug step by step to see in which line it crashes?



  • I tried to debug it step by step but it is impossible because it crashed before the first line.
    I have made a discovery, it is a problem of link with the dll. I made a comparison with another project which work. In the release repertory right aside the .exe file I found the following .dll :

    libeay32.dll
    libssh.dll
    libssh_threads.dll
    

    I took those dll and copy them in my release repertory and now it worked.
    I thought that the link was made with the file in the LibSSH directory but apparently it is not enough. I don't understand where I was supposed to find these dlls (I confess that I am not very used with the dlls)
    I am glad that I found the solution and very thankful for the time you spare to me.
    Now I still liked to know what was my mistake when I took the library libssh.

    Thanks to you all !


  • Moderators

    Well, the system is looking for libraries in specific locations like c:\windows and in the same directory where the exe is located. That's why it didn't find the DLLs.



  • How do we mark a subject as solved ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.