0

I’ve tried before and had little success in the full build but even that fails now and I'm obviously missing something on windows (and yes its probably windows :P)

can someone walk me through

  1. finding the correct OpenSSL to compile with libssh2
  2. actually cmake/compiling libssh2 into libgit2 cause it keeps saying cannot find libssh2 and I'm struggling to build it again.

I'm using CMake gui For windows, trying to build a VC2015 project

The error I was getting when building libgit2 is

checking for module 'libssh2'
  package 'libssh2' not found

LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.

even though I have put it in every possible place I can think it would look, and I have tried setting CMAKE_PREFIX_PATH ?

if anyone has successfully done it on windows I would appreciate a pointer or two as to what I'm doing wrong or should be doing

Thanks kindly Robert

Manos Nikolaidis
  • 21,608
  • 12
  • 74
  • 82
Saragan
  • 75
  • 3
  • 10

2 Answers2

5

libgit2 uses the cmake pkg-config module to find libssh2. The error message is probably wrong and misleading if you don't have pkg-config installed.

I've found that the easiest way to build libgit2 with libssh2 on windows is to turn off the USE_SSH option to prevent the pkg-config search, then manually set the necessary variables. The important ones are:

LIBSSH2_FOUND (set it to TRUE)
LIBSSH2_INCLUDE_DIRS
LIBSSH2_LIBRARY_DIRS
LIBSSH2_LIBRARIES

A similar thing can also be done for openssl.

Jason Haslam
  • 2,617
  • 13
  • 19
  • ok, will give it a go later :) thanks for the advice. I know what the first three are but what should LIBSSH2_LIBRARIES point too? – Saragan Dec 23 '15 at 08:38
  • Set LIBSSH2_LIBRARIES to any one of the items in the [target_link_library](https://cmake.org/cmake/help/latest/command/target_link_libraries.html) documentation. If you specify an imported target or the full path to the .lib file then you don't need to specify LIBSSH2_LIBRARY_DIRS. – Jason Haslam Dec 23 '15 at 17:44
  • I know that it is late but this solution does not work with me. It seems that the include variable is ignored exactly the same as CMAKE_PREFIX_PATH was. libssh2.h is not found --> no such file or directory. I guess I will have the same error with the library variables. – Fareanor Sep 03 '19 at 12:35
  • Including the headers and the .lib of libssh2 somewhere inside the libgit2 folder has solved the issue. It seems that the dependencies (as libssh2) have to be contained in the libgit2 tree to be properly found by CMake (on Windows). – Fareanor Sep 04 '19 at 06:37
0

Don't feel alone... building OpenSSL is so cryptic and challenging that entire websites have sprung-up to support this.

I typically download and check-in the LIB and don't bother... the code doesn't change and it saves build time as well.

Brycej
  • 64
  • 3
  • Ooo, that solves one of the three, thank you, instantly saved in favourites. Any idea on where libssh2 should be installed by default? – Saragan Dec 22 '15 at 23:04