Couldn't find LibSSH on msys2 even the libssh-devel has installed with pacman

1.4k views Asked by At

I'm trying to compile the libnetconf2 with msys2 environment on Windows 10 OS. But I get a wired(I guess) issue about libssh.

I have installed libssh libssh2 libssh-devel libssh2-devel and the pkg-config also find the location of libssh:

$ pkg-config --list-all
autoopts                       AutoOpts - A semi-automated generated/library option parser
form                           formw - ncurses 6.2 add-on library
formw                          formw - ncurses 6.2 add-on library
libalpm                        libalpm - Arch Linux package management library
libcrypto                      OpenSSL-libcrypto - OpenSSL cryptography library
libmagic                       libmagic - Magic number recognition library
libpcre                        libpcre - PCRE - Perl compatible regular expressions C library with 8 bit character support
libpcre16                      libpcre16 - PCRE - Perl compatible regular expressions C library with 16 bit character support
libpcre2-16                    libpcre2-16 - PCRE2 - Perl compatible regular expressions C library (2nd API) with 16 bit character support
libpcre2-32                    libpcre2-32 - PCRE2 - Perl compatible regular expressions C library (2nd API) with 32 bit character support
libpcre2-8                     libpcre2-8 - PCRE2 - Perl compatible regular expressions C library (2nd API) with 8 bit character support
libpcre2-posix                 libpcre2-posix - Posix compatible interface to libpcre2-8
libpcre32                      libpcre32 - PCRE - Perl compatible regular expressions C library with 32 bit character support
libpcrecpp                     libpcrecpp - PCRECPP - C++ wrapper for PCRE
libpcreposix                   libpcreposix - PCREPosix - Posix compatible interface to libpcre
libpkgconf                     libpkgconf - a library for accessing and manipulating development framework configuration
libssh                         libssh - The SSH Library
libssh2                        libssh2 - Library for SSH-based communication
libssl                         OpenSSL-libssl - Secure Sockets Layer and cryptography libraries

$ pkg-config --modversion libssh
0.9.6

And then run the command "cmake .." in

libnetconf2/build

, which gives the error:

$ cmake ..
CMake Warning at CMakeLists.txt:171 (message):
  valgrind executable not found! Disabling memory leaks tests.


-- Could NOT find CMocka (missing: CMOCKA_LIBRARIES CMOCKA_INCLUDE_DIR) (Required is at least version "1.0.1")
-- Disabling tests because of missing CMocka
-- Could NOT find Uncrustify (missing: UNCRUSTIFY) (Required is at least version "0.71")
-- OpenSSL found, required for TLS
CMake Error at /usr/share/cmake-3.21.3/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find LibSSH (missing: LIBSSH_LIBRARIES) (Required is at least
  version "0.7.1")
Call Stack (most recent call first):
  /usr/share/cmake-3.21.3/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  CMakeModules/FindLibSSH.cmake:113 (find_package_handle_standard_args)
  CMakeLists.txt:239 (find_package)


-- Configuring incomplete, errors occurred!

And then I try to compile libssh from source code, after compiling and installation, the cmake still can't find the correct libssh (Below is the log for libssh compile and install):

$ make install
Consolidate compiler generated dependencies of target ssh
[ 58%] Built target ssh
Consolidate compiler generated dependencies of target libssh_scp
[ 63%] Built target libssh_scp
Consolidate compiler generated dependencies of target sshnetcat
[ 68%] Built target sshnetcat
Consolidate compiler generated dependencies of target ssh-client
[ 73%] Built target ssh-client
Consolidate compiler generated dependencies of target scp_download
[ 78%] Built target scp_download
[ 80%] Built target libsshpp
Consolidate compiler generated dependencies of target samplesshd-cb
[ 82%] Built target samplesshd-cb
Consolidate compiler generated dependencies of target senddata
[ 87%] Built target senddata
Consolidate compiler generated dependencies of target exec
[ 92%] Built target exec
Consolidate compiler generated dependencies of target libsshpp_noexcept
[ 94%] Built target libsshpp_noexcept
Consolidate compiler generated dependencies of target keygen
[ 96%] Built target keygen
Consolidate compiler generated dependencies of target samplesftp
[100%] Built target samplesftp
Install the project...
-- Install configuration: ""
-- Installing: /usr/local/lib/pkgconfig/libssh.pc
-- Installing: /usr/local/lib/cmake/libssh/libssh-config-version.cmake
-- Installing: /usr/local/include/libssh/callbacks.h
-- Installing: /usr/local/include/libssh/libssh.h
-- Installing: /usr/local/include/libssh/ssh2.h
-- Installing: /usr/local/include/libssh/legacy.h
-- Installing: /usr/local/include/libssh/libsshpp.hpp
-- Installing: /usr/local/include/libssh/sftp.h
-- Installing: /usr/local/include/libssh/server.h
-- Installing: /usr/local/include/libssh/libssh_version.h
-- Installing: /usr/local/lib/libssh.dll.a
-- Installing: /usr/local/bin/msys-ssh-4.dll
-- Installing: /usr/local/lib/cmake/libssh/libssh-config.cmake
-- Installing: /usr/local/lib/cmake/libssh/libssh-config-noconfig.cmake

BTW, the LD_LIBRARY_PATH has added:

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
1

There are 1 answers

0
xiaoai On

I have resolved this issue as the link: Libgit2 and libssh2 CMake package 'libssh2' not found

/usr/local is the prefix path that I compiled and installed the libssh from source code.

cmake -DLIBSSH_INCLUDE_DIRS=/usr/local/include/libssh -DLIBSSH_LIBRARIES=/usr/local/lib/ ..