Compiling C++ code using libssh library through vcpkg

251 Views Asked by At

I installed libssh through vcpkg on my Windows 8.1 machine.

vcpkg install libssh

Now I am trying to compile my c++ code making use of libssh.

#include <libssh/libssh.h>
#include <stdlib.h>
 
int main()
{
  ssh_session my_ssh_session = ssh_new();
  if (my_ssh_session == NULL)
    exit(-1);
  ...
  ssh_free(my_ssh_session);
}

But I am receiving following error.

D:\remoteDesktopTimeZone>gcc sample.cpp -o sampl
sample.cpp:1:10: fatal error: libssh/libssh.h: No such file or directory
    1 | #include <libssh/libssh.h>
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
1

There are 1 best solutions below

0
vvv444 On BEST ANSWER

First, you should ensure that you are installing libraries with correct "triplet" matching your compiler and architecture. I don't know if your gcc is MingW or Cygwin. See instructions here.

Second, you should either use CMake as described here, or manually point the compiler where to find the library headers and static libraries using the -I and -L command line flags.