0

我正在尝试在 Windows 10 操作系统上使用msys2环境编译libnetconf2 。但我得到了一个关于 libssh 的有线(我猜)问题。

我已经安装了libssh libssh2 libssh-devel libssh2-devel并且pkg-config也找到了 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

然后在中运行命令“cmake ..”

libnetconf2/构建

,这给出了错误:

$ 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!

然后我尝试从源代码编译libssh,编译安装后,cmake仍然找不到正确的libssh(下面是libssh编译和安装的日志):

$ 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

顺便说一句,LD_LIBRARY_PATH 已添加:

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

1 回答 1

1

我已将这个问题作为链接解决: Libgit2 and libssh2 CMake package 'libssh2' not found

/usr/local是我从源代码编译和安装 libssh 的前缀路径。

cmake -DLIBSSH_INCLUDE_DIRS=/usr/local/include/libssh -DLIBSSH_LIBRARIES=/usr/local/lib/ ..
于 2021-10-19T10:38:04.240 回答