0

I'm by far no expert on C and even if the solution is righ there I can't see it. Have been trying this for 2 days now and I think I've given it my best.

Specs: Win7 x64, Compiler MinGW and CMake up and running

To use my compiler I issued in the downloaded folder in Desktop: cmake -G "MinGW Makefiles" After that, in the same folder I did: cmake --build .

Ended up at 100% and what seems to me without any error:

[100%] Linking C executable test_keyboard_interactive_auth_fails_with_wrong_response.exe [100%] Build target test_keyboard_interactive_auth_fails_with_wrong_response

Now my code is utterly simple, I just want to make it work but fails on the headers. I am following this tutorial http://api.libssh.org/master/libssh_tutorial.html and can't even make the first page work.

The headers I tried, that I can remember, are:

#include <libssh2.h> #include <libssh/libssh.h> #include <libssh.h>

and I get "No such file or directory" for any of the headers.


At home I managed to do something different: by adding the libssh.h library and its files manually to the folder I was working on and changing the headers to #include "libssh.h" After that I would not get that error but would raise a different one, something like "undefined reference to ssh_new" or something like that, can't remember now but can update on it later.

I would appreciate any help. I wouldnt mind compiling from Linux if its going to be easier but my target is to make an ssh server and a ssh client for windows (initially) and by myself - following that tutorial or another one.

Cheers everyone.

willem_tee
  • 21
  • 1
  • 2
  • You'll need to install the development package which will include header files and the library to link against. – Chris Turner Jan 30 '18 at 10:35
  • Thanks @Chris . Pardon me asking but what "development package" you refer to? Is it mingw, cmake, windows? – willem_tee Jan 30 '18 at 10:45
  • The one for libssh2 - no idea where you'd get it for Windows, but a quick google threw up this https://stackoverflow.com/questions/44889540/compiling-libssh2-on-windows – Chris Turner Jan 30 '18 at 10:53
  • Thanks, although it didn't solve my issue, helped me to change the error I was receiving. I give up though, going back to *nix for C. – willem_tee Feb 01 '18 at 15:44

1 Answers1

0

Two problems:

  • Your compiler cannot find the header file - you probably didn't tell where to look for.
  • You obviously do not link your program with libssh, that's why you get "undefined reference".

You should tell your visual studio that it should look for header files in the include directory of the libssh installation and secondly, it should link your program with libssh.

There are a lot of ways how to get there, the most widespread ones are using a build system or generator like CMake (or any other out there - there are a lot!) but of course you can as well simply point your visual studio to the correct locations.

If you use a library, you need access to the corresponding header files and you need to link to the library. The header files can be included with angle brackets (e.g. include <myheader.h>) if you tell your compiler that the folder is a system folder, otherwise you include them with quotes (e.g. include "myheader.h").

David
  • 93
  • 2
  • 7
  • Thanks David, have been trying several options along the week and although have managed to advance it is too difficult to set up in Windows. Even installing all the side libraries keeps giving errors and having *nix work like a charm I am not willing to further waste my time in Gate's creation. I will probably come back to it when I've improved my knowledge on C. Thanks for the suggestions. – willem_tee Feb 01 '18 at 15:46