Importing libssh into Qt

2.6k views Asked by At

I'm currently trying to import libssh into a Qt project I am working on. It appears that I have the library linked correctly as the project builds, but once I run the project it just crashes before anything really starts up. Which makes debugging difficult. If I comment out the line:

my_ssh_session = ssh_new();

Then everything runs as it should and no crash occurs. My .pro file looks like

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

QT += sql
QT += script
QT += scripttools
QT += uitools

LIBS += -llibssh

INCLUDEPATH += $$quote(C:\libssh\include)

TARGET = white_wrapper
TEMPLATE = app

SOURCES += main.cpp\
        mainwindow.cpp \
        datafeeder.cpp \
        dbfeeder.cpp \
        xmlhelper.cpp \
        hiddevice.cpp

HEADERS  += mainwindow.h \
         datasource.h \
         datafeeder.h \
         dbfeeder.h \
         xmlhelper.h \
         hiddevice.h

FORMS += mainwindow.ui

After looking online it looks like the problem could be dlls but after running a dll dependency application it looks like I have all the dlls needed so I guess I'm at a lose and would love some input thanks.

1

There are 1 answers

0
Honza Vojtěch On

I was getting the same error message with libssh-0.7.1, Qt 5.2.1 and MinGW.

After some research it turned up that libssh needs another two dynamic libraries which depends on: libeay32.dll and zlib1.dll. They are not included in libssh's distribution archive, therefore you have to download them yourself and copy next to libssh.dll (or somewhere on $PATH).

In my .pro file I have the following lines added (I installed libssh using their installer to Program Files (x86) directory):

# Libssh:
LIBS += -L$$PWD/'../../../../../Program Files (x86)/libssh/lib/' -lssh.dll
INCLUDEPATH += $$PWD/'../../../../../Program Files (x86)/libssh/include'
DEPENDPATH += $$PWD/'../../../../../Program Files (x86)/libssh/include'

Now my Qt application works without problems.