这是我第一次在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我知道有一些关于库链接的问题。我正在使用Netbeans作为我的IDE,并且对此还比较陌生。有谁能给我指点一下吗?我在网上搜索了很多,但大多数回复都是关于使用gcc在命令上编译的代码。如果有人能在Netbeans中帮忙的话。
发布于 2011-07-21 18:45:44
在Netbeans goto文件->项目属性->链接器->附加命令中我编写了-lssh2
发布于 2011-07-21 12:33:21
要编译该代码,您需要在系统中安装libssh2。这些未定义的引用来自头文件中包含的函数(并在代码中使用),这些函数需要链接到实现它们的库。
#include <libssh2.h>
#include <libssh2_sftp.h>安装libssh2后,必须将标志-lssh2添加到编译器中。我不知道Netbeans,所以我不能帮你。浏览项目选项并查找有关编译器参数/标志的内容。
https://stackoverflow.com/questions/6761957
复制相似问题