2

I am trying to build source of libgit2 on windows 8 using visual studio command prompt 2010. I have also compiled & install libssh2 source successfully on machine.

libssh2 installed path : C:\Program Files (x86)\libssh2

Whenever I am executing command cmake .. for libgit2 CMake.list, I am getting output as LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.

I have tried several suggestions which is available on stackoverflow as well, but there is no luck. Also I tried to put libssh2 compiled folder including sub-directories (include, lib & share) in cmake/Modules folder of libgit2.

Anybody suggest me what is the correct way to configure external dependency in CMakelist.txt for including libssh2 module in libgit2?

Thanks in advance!

Monty
  • 71
  • 1
  • 13
  • Where `.pc` file for `libssh2` is located? (Probably, it is somewhere under installed path of this library). Try to set CMAKE_PREFIX_PATH to the *directory*, where this file is: `cmake -DCMAKE_PREFIX_PATH= `. – Tsyvarev Nov 09 '15 at 09:56
  • @Tsyvarev : Yes, .pc file is available in C:\Program Files (x86)\libssh2\lib\pkgconfig directory, I have set CMAKE_PREFIX_PATH as well, but there is no effect of this..... – Monty Nov 09 '15 at 10:26
  • Hm, it seems from the `pkg_check_modules` [implementation](https://github.com/Kitware/CMake/blob/master/Modules/FindPkgConfig.cmake#L271) that `lib/pkgconfig` suffix is added automatically. Could you try to set CMAKE_PREFIX_PATH to `C:\Program Files (x86)\libssh2` instead? – Tsyvarev Nov 09 '15 at 11:03
  • @Tsyvarev : Tried to change & check, still same error.....! – Monty Nov 09 '15 at 11:19
  • Looks strange. Actually, you need to adjust `pkg-config` tool to find your `libssh2` library. The only way I know for achive that is setting `PKG_CONFIG_PATH` envoronment variable. You can play with it, assigning it different subpaths of `.pc` file. Once you succeed with that, configuration of `libgit2` should be succeed, while running from the same environment. – Tsyvarev Nov 09 '15 at 11:30
  • What version of CMake are you using? CMAKE_PREFIX_PATH is not evaluated with older CMake version and pkg-config. – usr1234567 Nov 09 '15 at 12:44

1 Answers1

2

The CMake script uses pkg-config to find the dependencies (with a few OS-specific exceptions for libraries shipped with the base install) so if you have libssh2 in a place other than where your pkg-config would look, you'll have to set PKG_CONFIG_PATH.

Note that if you've built libssh2 in a mingw environment, it might not work with a MSVC-built libgit2.

On master and the 0.22 release, you can also embed libssh2 in the libgit2 dll by setting EMBED_SSH_PATH to a recent release of libssh2 which can use Windows' crypto libraries instead of OpenSSL. But if you can build a libssh2 dll, that's the preferred option.

Carlos Martín Nieto
  • 5,207
  • 1
  • 15
  • 16
  • could you please suggest where I can get 0.22 release source code ? I have pull master branch but it's version is higher than 0.22. – Monty Nov 18 '15 at 11:12
  • If you have cloned, you already have the version, checkout the v0.22.3 tag, or go to the project's GitHub page and click on 'Releases' and select whichever version you want. – Carlos Martín Nieto Nov 18 '15 at 20:17
  • Thanks for suggestion, I am able to get 0.22 release now. I am just compile it it is also saying that "Protocol is not supported". Now i am using simple Http repository url instead of SSH. My repo url is like [http://subdomain.domain:82/abc.git](http://subdomain.domain:82/abc.git) but whenever I am using git_clone method it throws error **Request failed with status code: 401**. But when I am trying same url on Git Bash it clone successfully. I am using git_cred_userpass_plaintext_new method for setting credentials. Could you please suggest me what I am doing wrong ? – Monty Nov 20 '15 at 15:02
  • any suggestion on my above comment ? – Monty Nov 21 '15 at 05:42
  • That means the server didn't accept the credentials. Double-check the username and password, and whether you need a particular token to access via Git rather than the webpage. – Carlos Martín Nieto Nov 21 '15 at 09:37
  • Then either you're not setting it in the options you pass to clone, or there might be a bug somewhere, but that's an old version of libgit2, and without seeing your code it's not possible to know what's happening. This is also completely different from the subject of the question. – Carlos Martín Nieto Nov 21 '15 at 12:44
  • I am setting git_clone_options clone_opts = GIT_CLONE_OPTIONS_INIT; clone_opts.fetch_opts.callbacks.credentials = &cred_acquire_cb; which is working for bitbucket repository. I have setup repository on my server, might be there is issue with my server setup, because I am not getting callback from server side..... Also I will make another post for this issue with new subject line. Thanks for your help. – Monty Nov 21 '15 at 13:16