I am currently trying to create a c program that shall ssh into a couple of remote servers. I am attempting to link the libssh library to my program but I am having difficulty. This is my main source file:
#include <stdio.h>
#include <stdlib.h>
#define LIBSSH_STATIC 1
#include "libssh/libssh.h"
int main(){\n
printf("Attempting Library Call!\n");
ssh_session my_ssh_session=ssh_new();
printf("Exiting Program!\n");
ssh_free(my_ssh_session);
return (EXIT_SUCCESS);
}
Makefile:
all:
gcc -Wall -g -I/home/user/SSH_CON/libssh/include -L/home/user/SSH_CON/libssh/lib main.c -o ssh -lssh
This is the first time I am attempting to link a library with a c program and I have having difficulty. The downloaded files that came with the library from https://www.libssh.org/ installer are as follows:
/libssh
/bin
libssh.dll
libssh_threads.dll
/CMake
libssh-config.cmake
libssh-config-version.cmake
/include/libssh
callbacks.h
legacy.h
libssh.h
server.h
sftp.h
ssh2.h
/lib
/pkgconfig
libssh.pc
libssh_threads.pc
libssh.dll.a
libssh_threads.dll.a
Uninstall.exe
I have done a lot of searching online, and have tried adding both the libssh.dll and the libssh.dll.a libraries. The gcc is successful in making the ssh.exe executable, but when I try to run it, I consistently receive this error:
/home/user/SSH_CON/ssh.exe: error while loading shared libraries: libssh.dll: cannot open shared object file: no such file or directory
I have no idea where to go from here. Does anyone have any suggestions?
UPDATE:
Placed the libssh.dll.a and libssh.dll into the working directory of my main.c file and now I am receiving this error:
/home/user/SSH_CON/ssh.exe: error while loading shared libraries: ?: cannot open shared object file: no such file or directory
Running ldd on my executable produced the following result:
ntdll.dll => /cygdrive/c/Windows/SYSTEM32/ntdll.dll
KERNEL32.DLL => /cygdrive/c/Windows/SYSTEM32/KERNEL32.DLL
KERNELBASE.dll => /cygdrive/c/Windows/SYSTEM32/KERNELBASE.dll
cygwin1.dll => /usr/bin/cygwin1.dll
libssh.dll => /home/user/SSH_CON/libssh.dll
ADVAPI32.DLL => /cygdrive/c/Windows/SYSTEM32/ADVAPI32.DLL
msvcrt.dll => /cygdrive/c/Windows/SYSTEM32/msvcrt.dll
SHELL32.DLL => /cygdrive/c/Windows/SYSTEM32/SHELL32.DLL
WS2_32.DLL => /cygdrive/c/Windows/SYSTEM32/WS2_32.DLL
Is there any way I can identify the missing library named ?
? Is there any way I can compile this library to be static so that at runtime it does not depend on any shared libraries?