I have filed an issue on libssh git. This is an link issue, I'm not sure if it is about libnetconf2 or libssh.
Environment: msys2 + mingw64
OS: Win10
Installed packages: libssh-devel with pacman, version: 0.9.6
$ pkg-config --modversion libssh
0.9.6
libssh installed location:
$ find / -name "*libssh*"
/usr/include/libssh
/usr/include/libssh/libssh.h
/usr/include/libssh/libsshpp.hpp
/usr/include/libssh/libssh_version.h
/usr/lib/cmake/libssh
/usr/lib/cmake/libssh/libssh-config-noconfig.cmake
/usr/lib/cmake/libssh/libssh-config-version.cmake
/usr/lib/cmake/libssh/libssh-config.cmake
/usr/lib/libssh.dll.a
/usr/lib/pkgconfig/libssh.pc
I'm try to compile the libnetconf2
with cmake:
- If just run the
cmake ..
in build folder, the cmake can't find the correct location of libssh:
cmake ..
-- Found OpenSSL: /usr/lib/libcrypto.dll.a (found version "1.1.1l")
-- 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!
- You have to run the cmake with some additional flags to generate the right make files:
cmake -DLIBSSH_INCLUDE_DIRS=/usr/include/libssh -DLIBSSH_LIBRARIES=/usr/lib/ ..
- And then run the make command, which will generate a lot of
undefined reference
to error:
[ 53%] Building C object CMakeFiles/netconf2.dir/src/session_server.c.o
[ 61%] Building C object CMakeFiles/netconf2.dir/src/session_client_ssh.c.o
[ 69%] Building C object CMakeFiles/netconf2.dir/src/session_server_ssh.c.o
[ 76%] Building C object CMakeFiles/netconf2.dir/src/session_client_tls.c.o
[ 84%] Building C object CMakeFiles/netconf2.dir/src/session_server_tls.c.o
[ 92%] Building C object CMakeFiles/netconf2.dir/compat/compat.c.o
[100%] Linking C shared library msys-netconf2-2.dll
/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/bin/ld: CMakeFiles/netconf2.dir/src/io.c.o: in function `nc_read':
/g/Programming/netconf/libnetconf2/src/io.c:143: undefined reference to `__imp_ssh_channel_read'
/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/bin/ld: /g/Programming/netconf/libnetconf2/src/io.c:148: undefined reference to `__imp_ssh_get_error'
/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/bin/ld: /g/Programming/netconf/libnetconf2/src/io.c:153: undefined reference to `__imp_ssh_channel_is_eof'
/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/bin/ld: CMakeFiles/netconf2.dir/src/io.c.o: in function `nc_read_poll':
/g/Programming/netconf/libnetconf2/src/io.c:483: undefined reference to `__imp_ssh_channel_poll_timeout'
/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/bin/ld: /g/Programming/netconf/libnetconf2/src/io.c:485: undefined reference to `__imp_ssh_get_error'
/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/bin/ld: CMakeFiles/netconf2.dir/src/io.c.o: in function `nc_session_is_connected':
/g/Programming/netconf/libnetconf2/src/io.c:615: undefined reference to `__imp_ssh_is_connected'
/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/bin/ld: CMakeFiles/netconf2.dir/src/io.c.o: in function `nc_write':
/g/Programming/netconf/libnetconf2/src/io.c:697: undefined reference to `__imp_ssh_channel_is_closed'
/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/bin/ld: /g/Programming/netconf/libnetconf2/src/io.c:697: undefined reference to `__imp_ssh_channel_is_eof'
/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/bin/ld: /g/Programming/netconf/libnetconf2/src/io.c:698: undefined reference to `__imp_ssh_channel_is_closed'
/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/bin/ld: /g/Programming/netconf/libnetconf2/src/io.c:707: undefined reference to `__imp_ssh_channel_write'
/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/bin/ld: CMakeFiles/netconf2.dir/src/log.c.o: in function `nc_libssh_thread_verbosity':
.... ...
/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/bin/ld: /g/Programming/netconf/libnetconf2/src/session_server_ssh.c:1497: undefined reference to `__imp_ssh_bind_accept_fd'
/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/bin/ld: /g/Programming/netconf/libnetconf2/src/session_server_ssh.c:1498: undefined reference to `__imp_ssh_get_error'
/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/bin/ld: /g/Programming/netconf/libnetconf2/src/session_server_ssh.c:1500: undefined reference to `__imp_ssh_bind_free'
/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/bin/ld: /g/Programming/netconf/libnetconf2/src/session_server_ssh.c:1503: undefined reference to `__imp_ssh_bind_free'
/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/bin/ld: /g/Programming/netconf/libnetconf2/src/session_server_ssh.c:1505: undefined reference to `__imp_ssh_set_blocking'
/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/bin/ld: /g/Programming/netconf/libnetconf2/src/session_server_ssh.c:1511: undefined reference to `__imp_ssh_handle_key_exchange'
/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/bin/ld: /g/Programming/netconf/libnetconf2/src/session_server_ssh.c:1525: undefined reference to `__imp_ssh_get_error'
/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/bin/ld: /g/Programming/netconf/libnetconf2/src/session_server_ssh.c:1540: undefined reference to `__imp_ssh_execute_message_callbacks'
/usr/lib/gcc/x86_64-pc-msys/10.2.0/../../../../x86_64-pc-msys/bin/ld: /g/Programming/netconf/libnetconf2/src/session_server_ssh.c:1541: undefined reference to `__imp_ssh_get_error'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/netconf2.dir/build.make:276: msys-netconf2-2.dll] Error 1
make[1]: *** [CMakeFiles/Makefile2:137: CMakeFiles/netconf2.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
- Check the
/usr/lib/libssh.dll.a
file, the undefined functions exists in it:
$ objdump -t /usr/lib/libssh.dll.a | grep __
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_string_to_char
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_string_new
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_string_len
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_string_from_char
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_string_free
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_string_fill
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_string_data
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_string_copy
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_string_burn
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_write_knownhost
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_version
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_userauth_try_publickey
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_userauth_publickey_auto
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_userauth_publickey
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_userauth_pubkey
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_userauth_privatekey_file
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_userauth_password
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_userauth_offer_pubkey
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_userauth_none
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_userauth_list
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_userauth_kbdint_setanswer
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_userauth_kbdint_getprompt
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_userauth_kbdint_getnprompts
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_userauth_kbdint_getnanswers
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_userauth_kbdint_getname
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_userauth_kbdint_getinstruction
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_userauth_kbdint_getanswer
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_userauth_kbdint
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_userauth_gssapi
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_userauth_autopubkey
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_userauth_agent_pubkey
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_userauth_agent
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_try_publickey_from_file
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_threads_set_callbacks
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_threads_get_pthread
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_threads_get_noop
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_threads_get_default
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_string_to_char
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_string_new
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_string_len
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_string_get_char
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_string_from_char
$ objdump -t /usr/lib/libssh.dll.a | grep __imp_ssh_bind_free
[ 6](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 0) 0x0000000000000000 __imp_ssh_bind_free
Those are all information I can find, could someone have the same issue with msys2 (for pure linux, like CentOS, there is no such issue)?