how to integrate libssh with windows QT Creator 11.0.2
-
I need to make an application that runs in Raspberrypi where I can transfer files using ssh from the host Windows machine to the remote pi. and also execute a few read-a-file commands there.
Hence I have to use these lines
"#include <libssh/libssh.h>"i did installed the libssh using vcpkg. please find the logs " .\vcpkg list
libssh:x64-windows 0.10.5 libssh is a multiplatform C library implementing...
libssh:x86-windows 0.10.5 libssh is a multiplatform C library implementing...
libssh[crypto]:x64-windows Default crypto backend
libssh[crypto]:x86-windows Default crypto backend
libssh[mbedtls]:x64-windows Crypto support (mbedTLS)
libssh[mbedtls]:x86-windows Crypto support (mbedTLS)
mbedtls:x64-windows 2.28.1 An open source, portable, easy to use, readable ...
mbedtls:x86-windows 2.28.1 An open source, portable, easy to use, readable ...
mbedtls[pthreads]:x64-windows Multi-threading support
mbedtls[pthreads]:x86-windows Multi-threading support
pthreads:x64-windows 3.0.0#14 Meta-package that provides PThreads4W on Windows...
pthreads:x86-windows 3.0.0#14 Meta-package that provides PThreads4W on Windows...
vcpkg-cmake-config:x64-windows 2022-02-06#1
vcpkg-cmake:x64-windows 2023-05-04"yet eventhough i am able to incude the libssh files into .pro fiel like this
INCLUDEPATH += C:/Users/****/vcpkg/installed/x64-windows/include
LIBS += -LC:C:/Users/*****/vcpkg/installed/x64-windows/libi cant build the libssh.h included files. please fine a sample function to connect SSHManager::SSHManager() : sshSession(nullptr) {
sshSession = ssh_new();
}SSHManager::~SSHManager() {
if (sshSession) {
ssh_disconnect(sshSession);
ssh_free(sshSession);
}
}it throws the below linker error "sshmanager.obj:-1: error: LNK2019: unresolved external symbol __imp_ssh_new referenced in function "public: __cdecl SSHManager::SSHManager(void)" (??0SSHManager@@QEAA@XZ)"
please help with how to integrate the libssh into QT?
-
@solo_engineer said in how to integrate libssh with windows QT Creator 11.0.2:
LIBS += -LC:C:/Users/*****/vcpkg/installed/x64-windows/lib
This is wrong.
First: one "C:" not two of them.
Second: you also need to specify the lib to link, not just the folder where the lib is.
On Windows you need to use the *.lib file with -l:LIBS += -lC:/Users/*****/vcpkg/installed/x64-windows/lib/LIB_TO_LINK.lib
-
Gratitude for the reply.
I changed the .pro file the same.
and now I could build the functions to connect and disconnect like this "SSHManager::SSHManager() : sshSession(nullptr) {
sshSession = ssh_new();
}SSHManager::~SSHManager() {
if (sshSession) {
ssh_disconnect(sshSession);
ssh_free(sshSession);
}
} "Yet I am unable to create the release version of the app.
It throws an error like this "The code execution cannot proceed because ssh.dll was not fouynd. reinstalling the program mag fix this problem"
Also this is the QT.pro file
"CONFIG += c++17INCLUDEPATH += "C:/Users/***/vcpkg/installed/x64-windows/include"
#LIBS += -L"C:/Users//vcpkg/installed/x64-windows/lib" -lssh
LIBS += -lC:/Users//vcpkg/installed/x64-windows/lib/ssh.lib"Also the contents of the echo $PATH command in my system:
C:\Program Files (x86)\VMware\VMware Player\bin;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\OpenSSH;C:\Program Files\dotnet;C:\Program Files\PuTTY;C:\MinGW\bin;C;C:\Program Files\Graphviz\bin;C:\Program Files\Microchip\xc8\v2.41\bin;C:\Users*\vcpkg\installed\x64-windows\bin\ssh.dll;C:\Users**\AppData\Local\Microsoft\WindowsApps;please do let me how to create the release version of the app with libssh.
-
@solo_engineer
PFB the path command output
"echo %PATH%
C:\Program Files (x86)\VMware\VMware Player\bin;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\OpenSSH;C:\Program Files\dotnet;C:\Program Files\PuTTY;C:\MinGW\bin;C;C:\Program Files\Graphviz\bin;C:\Program Files\Microchip\xc8\v2.41\bin;C:\Users*\vcpkg\installed\x64-windows\bin\ssh.dll;C:\Users*\AppData\Local\Microsoft\WindowsApps;C:\Users*\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users*\AppData\Local\Programs\Git\cmd;C:\Users**\AppData\Local\GitHubDesktop\bin"" -
@solo_engineer To execute your app you need the dll version of the lib. You can put it next to the app executable.