这是我第一次在C. im的项目中工作,只是想创建一个SSH客户端。libssh2 C编译
我的代码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
我知道有一些库连接问题。我使用Netbeans作为我的IDE,并且相对比较新。任何人都可以请指导我。我在互联网上搜索了很多,但大多数回复与使用gcc在命令中编译的代码有关。如果有人可以帮助Netbeans。
libssh2已安装。你的方法在命令行上工作。仍然无法弄清netbeans –
我也想知道-lssh2的逻辑是什么?我的意思是你怎么知道这个关键字。 –
因为它是libssh2。编译器标志是-l后面跟着没有'lib'的lib名称。例如,如果你想包含数学库(libm),你可以添加标志-lm – nmat