0

I'm trying to use libssh on Windows 10 with gcc. The work is being done from the command line.

I don't know how to make libssh/ part of the search path.

The #include was libssh/libssh.h, but that failed. (The brackets were left out of this sentence.)

#include <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);
}

When I modify the include statement to be just libssh.h and use the following on the command line:

gcc -IC:\libssh\include\libssh ssh.c -oout.exe

That works to get past the libssh.h file not found.

But, the other files that are called, such as libssh/legacy.h are not found.

How do I get the libssh to be part of the search path?

I added c:\libssh\include\libssh to the environment path. That didn't work.

Just Nuts
  • 1
  • 2

1 Answers1

0

You need to let #include <libssh/libssh.h> because libssh.h call a header legacy.h which is also located in the libssh folder so if you put directly the header libssh.h it won't be able to locate legacy.h

#include <libssh/libssh.h> 
#include <stdlib.h>
int main()
{
  ssh_session my_ssh_session = ssh_new();
  if (my_ssh_session == NULL)
    exit(-1);
  // remove the dots it'll create an error
  ssh_free(my_ssh_session);
}

to have libssh a part of the path you should do gcc -I/path/to/libssh/include/directory -L/path/to/libssh/lib/directory -lssh ssh.c oout.exe

I also got stuck into that, now I face another issue, the one to link the libssh.dll or ssh.dll inside the compiled code to use it as stand-alone.

Mansa
  • 1