libssh2 C 编译

Han*_*i Q 5 c ssh linker netbeans

这是我第一次用 C 做一个项目。我只是想制作一个 SSH 客户端。

我的代码是从 libssh2 站点复制的

http://www.libssh2.org/examples/ssh2.html

但是当我运行它时,我收到以下错误?

main.o: In function `main':
main.c:(.text+0xbe): undefined reference to `libssh2_init'
main.c:(.text+0x1a7): undefined reference to `libssh2_session_init_ex'
main.c:(.text+0x1bf): undefined reference to `libssh2_session_startup'
main.c:(.text+0x209): undefined reference to `libssh2_hostkey_hash'
main.c:(.text+0x282): undefined reference to `libssh2_userauth_list'
main.c:(.text+0x3e3): undefined reference to `libssh2_userauth_password_ex'
main.c:(.text+0x443): undefined reference to `libssh2_userauth_keyboard_interactive_ex'
main.c:(.text+0x4b9): undefined reference to `libssh2_userauth_publickey_fromfile_ex'
main.c:(.text+0x529): undefined reference to `libssh2_channel_open_ex'
main.c:(.text+0x58d): undefined reference to `libssh2_channel_setenv_ex'
main.c:(.text+0x5d9): undefined reference to `libssh2_channel_request_pty_ex'
main.c:(.text+0x633): undefined reference to `libssh2_channel_process_startup'
main.c:(.text+0x674): undefined reference to `libssh2_channel_free'
main.c:(.text+0x6a0): undefined reference to `libssh2_session_disconnect_ex'
main.c:(.text+0x6ac): undefined reference to `libssh2_session_free'
main.c:(.text+0x6c9): undefined reference to `libssh2_exit'
collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

我知道库链接存在一些问题。我使用 Netbeans 作为我的 IDE,对此我比较陌生。任何人都可以请指导我。我在网上查了很多,但大部分回复与使用gcc在命令上编译的代码有关。如果有人可以在 Netbeans 中提供帮助。

Han*_*i Q 4

明白了,在 Netbeans 中转到文件 -> 项目属性 -> 链接器 -> 我写的附加命令 -lssh2