[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Function behaves differently when libssh is compiled statically
[Thread Prev] | [Thread Next]
[Date Prev] | [Date Next]
- Subject: Function behaves differently when libssh is compiled statically
- From: petergeorgenm <petergeorgenm@xxxxxxxxxxxxxx>
- Reply-to: petergeorgenm <petergeorgenm@xxxxxxxxxxxxxx>
- Reply-to: libssh@xxxxxxxxxx
- Date: Mon, 01 Feb 2021 13:04:18 +0000
- To: "libssh@xxxxxxxxxx" <libssh@xxxxxxxxxx>
I wrote a simple connection setup following the tutorial: //main.c #pragma comment(lib, "user32") #pragma comment(lib, "Advapi32") #pragma comment(lib, "Shell32") #pragma comment(lib, "Ws2_32") #include <stdio.h> #include <libssh/sftp.h> #include <sys/stat.h> #include <fcntl.h> int main(void){ int ret_c=0; int rc; int port=22; ssh_session the_session=ssh_new(); if(the_session==NULL) {printf("1\n"); return -1;} ssh_options_set(the_session, SSH_OPTIONS_HOST, "user@1.2.3.4"); ssh_options_set(the_session, SSH_OPTIONS_PORT, &port); rc=ssh_connect(the_session); if(rc !=SSH_OK) { ssh_free(the_session); printf("2, %d\n", rc); getchar(); } else { printf("success\n"); getchar(); } ssh_disconnect(the_session); ssh_free(the_session); return 0; } I used vcpkg to install both static and dynamic versions of libssh, they reside as follows respectively: C:\Users\User\vcpkg\installed\x86-windows-static\ C:\Users\User\vcpkg\installed\x86-windows\ If I compile the previous code dynamically with: cl /I C:\Users\User\vcpkg\installed\x86-windows\include main.c /link C:\Users\User\vcpkg\installed\x86-windows\lib\* /SUBSYSTEM:CONSOLE and then run, the output I see is: success If I compile it statically with: cl /D LIBSSH_STATIC /I C:\Users\User\vcpkg\installed\x86-windows-static\include main.c /link C:\Users\User\vcpkg\installed\x86-windows-static\lib\* /SUBSYSTEM:CONSOLE and then run, the output I see is: 2, -1 Both versions compile and link without any errors. I also tried to use putty to ssh to user@1.2.3.4 and it works fine. Please tell me if I need to provide any more debugging information, or if any information isn't clear. Thank you in advance. Regards, Peter.
Re: Function behaves differently when libssh is compiled statically | Anderson Sasaki <ansasaki@xxxxxxxxxx> |