嗨,我是一个全新的c++新手,我正在尝试建立一个ssh连接,这里是我的代码,它被指出给我,我需要链接库…这是怎么做的?
#include <libssh/libssh.h>
#include <stdlib.h>
int main()
{
ssh_session my_ssh_session;
my_ssh_session = ssh_new();
int verbosity = SSH_LOG_PROTOCOL;
int port = 22;
ssh_options_set(my_ssh_session, SSH_OPTIONS_HOST, "localhost");
ssh_options_set(my_ssh_session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
ssh_options_set(my_ssh_session, SSH_OPTIONS_PORT, &port);
ssh_free(my_ssh_session);
}我一直收到这个错误
[brett@badbox sshcpp1]$ make
g++ -Wl,-O1 -Wl,-z,relro -o sshcpp1 main.o -lQt5Core -lpthread
main.o: In function `main':
/home/brett/sshcpp1/main.cpp:7: undefined reference to `ssh_new'
/home/brett/sshcpp1/main.cpp:10: undefined reference to `ssh_options_set'
/home/brett/sshcpp1/main.cpp:11: undefined reference to `ssh_options_set'
/home/brett/sshcpp1/main.cpp:12: undefined reference to `ssh_options_set'
/home/brett/sshcpp1/main.cpp:13: undefined reference to `ssh_free'
collect2: error: ld returned 1 exit status
make: *** [sshcpp1] Error 1Outocomplete似乎正在使用ssh库。
我做错了什么??
发布于 2018-09-22 15:04:28
您需要通过将-lssh添加到链接器命令来链接libssh。
https://stackoverflow.com/questions/52453887
复制相似问题