I am a beginner in C++ and I am trying to build ssh.dll
on Windows 32bit using Visual Studio 2017 and cmake
. I have downloaded the latest version of libssh
and tried to build ssh.dll
from the source by using cmake
after configuring and generating as per the recommended steps.
After generating, I opened the libssh solution file with Visual Studio 2017 and build it but while compiling it gave few missing library errors which I resolved by adding those libraries to the VC path.
After adding those libraries, it started giving me around 600 compilation errors like below related to syntax (but syntax looks correct in these library files) .
Is there a way or suggestion by which I can successfully resolve them and create .dll file ?
Below are some of those errors:
Severity Code Description Project File Line Suppression State
Error C2146 syntax error: missing ')' before identifier 'session' ssh_shared c:\apps\mvs15\vc\tools\msvc\14.10.25017\include\libssh\priv.h 196
Error C2061 syntax error: identifier 'channel' ssh_shared c:\apps\mvs15\vc\tools\msvc\14.10.25017\include\libssh\callbacks.h 64
Error C2059 syntax error: ';' ssh_shared c:\apps\mvs15\vc\tools\msvc\14.10.25017\include\libssh\callbacks.h 64
Error C2146 syntax error: missing ')' before identifier 'fd' ssh_shared c:\apps\mvs15\vc\tools\msvc\14.10.25017\include\libssh\libssh.h 656
Error C2059 syntax error: ')' ssh_shared c:\apps\mvs15\vc\tools\msvc\14.10.25017\include\libssh\libssh.h 597
Error C2081 'socket_t': name in formal parameter list illegal ssh_shared c:\apps\MVS15\VC\Tools\MSVC\14.10.25017\include\libssh\poll.h 135
Error C2059 syntax error: '}' ssh_shared c:\apps\MVS15\VC\Tools\MSVC\14.10.25017\include\libssh\session.h 203
Error C2146 syntax error: missing ')' before identifier 'fd' ssh_shared c:\apps\MVS15\VC\Tools\MSVC\14.10.25017\include\libssh\socket.h 36
Error C2059 syntax error: ';' ssh_shared c:\apps\mvs15\vc\tools\msvc\14.10.25017\include\libssh\callbacks.h 64
Error C2037 left of 'iqmp' specifies undefined struct/union 'rsa_st' ssh_shared C:\apps\vcpkg\downloads\libssh-0.7.6.tar\libssh-0.7.6\src\libcrypto-compat.c 77
Error C2037 left of 'dmq1' specifies undefined struct/union 'rsa_st' ssh_shared C:\apps\vcpkg\downloads\libssh-0.7.6.tar\libssh-0.7.6\src\libcrypto-compat.c 76
In order to resolve it, I also tried to replace the questionable library files with other version of these library files, but without any luck. What can I try next?
I just git a git clone and build it successfully.
Here is how I did it.
vcpkg install zlib:x64-windows openssl:x64-windows
# in vcpkg installed directory:
mkdir build
cd build
cmake .. -DCMAKE_GENERATOR_PLATFORM=x64 "-DCMAKE_TOOLCHAIN_FILE=C:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake"
For static linking include -DVCPKG_TARGET_TRIPLET=x86-windows-static
Open the solution file in Visual Studio 2017 and it successfully builds.
2> Creating library ssh.lib
2>ssh_shared.vcxproj -> ....\build\src\Debug\ssh.dll
========== Build: 7 succeeded, 0 failed, 0 up-to-date, 4 skipped ==========
If you want to build for 32 bit architecture
vcpkg install zlib openssh
in the cloned source code
mkdir build
cd build
cmake .. "-DCMAKE_TOOLCHAIN_FILE=C:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake"