I've been struggling to compile stand-alone exe with i686-w64-mingw32-gcc using libssh;
#define LIBSSH_STATIC 1
#include <libssh/libssh.h>
#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
int main() {
ssh_session my_ssh_session;
int rc;
char *password;
int port = 22;
my_ssh_session = ssh_new();
if (my_ssh_session == NULL)
exit(-1);
ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, "myhost.com");
ssh_options_set(my_ssh_session, SSH_OPTIONS_PORT, &port);
ssh_options_set(my_ssh_session, SSH_OPTIONS_USER, "user");
rc = ssh_connect(my_ssh_session);
password = ("mypassword");
rc = ssh_userauth_password(my_ssh_session, NULL, password);
ssh_disconnect(my_ssh_session);
ssh_free(my_ssh_session);
I compile this code with following command:
i686-w64-mingw32-gcc ssh_client2.c -o client_v2.exe -I/tmp/lib/libssh-0.7.2/include/ -lssh -L/tmp/lib/libssh-0.7.2/lib -L/tmp/libssh-0.7.2/lib -static
I have libssh-0.7.2-mingw.zip extracted in:
/tmp/lib/libssh-0.7.2/lib
And libssh-0.7.2-msvc.zip in - couldn't compile at all without libssh.lib
-L/tmp/libssh-0.7.2/bin
The code compiles but when running with wine, it still looks for ssh.dll:
err:module:import_dll Library ssh.dll (which is needed by L"Z:\\location\\of\\exe\\client_v2.exe") not found
Environment:
i686-w64-mingw32-gcc (GCC) 6.3.0 20170516
Linux l6453p 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u5 (2017-09-19) x86_64 GNU/Linux
wine-1.8.7 (Debian 1.8.7-2)
What am i missing here? Am i even doing this in the proper way with using two different libssh-packages? I tried both #define LIBSSH_STATIC 1 and #define LIBSSH_STATIC but these don't seem to make any difference and i can't seem to find way to manually tell the compiler to include ssh.dll with any switch.