0

Is exist any guide for libssh2 C++? I have no any idea why the lnk2019 apears when i try to use any function from libssh2 but i linked this library and included in code.

#include <libssh2_config.h>
#include <libssh2.h>
#include <libssh2_sftp.h>
#include <WinSock2.h>
#include <iostream>

int main()
{
    if (libssh2_init(0) != 0) {
        return 1;
    }
}

Even in this simple code that i want to compile.

I tried search and use any tips how i can solve the problem but it didn't compile due the error LNK2019

  • What is the exact error message? A link error means you have not linked all required libraries. – Retired Ninja May 06 '23 at 19:10
  • I added all extra includes of libssh2 into VC, but it continue print the lnk2019 error about "libssh2_init" in main function. For more accurate "reference to unresolved external symbol libssh2_init in main function" – mAlware_w0lf May 06 '23 at 21:06
  • Includes are one part. Linking libraries is another. It sounds like you have missed that step. – Retired Ninja May 06 '23 at 21:08
  • Now I began to understand even less, because I included files in the project settings as usual, but in this library there were no .lib files in principle and only files of the .h format – mAlware_w0lf May 06 '23 at 21:18
  • Perhaps you have `.a` files which are not for Visual Studio or you need to compile something. Really hard to guess since we still do not know the error messages you received. – Retired Ninja May 06 '23 at 21:50
  • "Ошибка LNK2019 ссылка на неразрешенный внешний символ libssh2_init в функции main" or "Error linking LNK2019 to unresolved external symbol libssh2_init in main function". I looked at the library and i see most of cmake files – mAlware_w0lf May 06 '23 at 22:00
  • 1
    There are instructions for how to build and use the library here: https://github.com/libssh2/libssh2/blob/master/docs/INSTALL_CMAKE.md You might be better off using something like vcpkg https://vcpkg.io/en/ – Retired Ninja May 06 '23 at 22:57

0 Answers0