来到 libssh 官网, 跟随着 tutorial 熟悉使用 libssh。
然而一开始我就遇到了困难。 chapter 1 中的第一段代码, 我总是没有办法编译通过。
文件名 main.c
#include <libssh/libssh.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
ssh_session my_ssh_session = ssh_new();
if (my_ssh_session == NULL)
exit(-1);
ssh_free(my_ssh_session);
}
最终我找到了一篇关于使用 libssh 的博客: 使用 libssh 编写 client
原来是我在用 gcc 命令编译的时候没有使用适当的参数:
gcc main.c -o main # 编译失败
gcc main.c -o main -Wall -lssh # 编译成功
- -Wall 生成所有警告信息
- -lssh 暂时不明作用
在此感谢 使用 libssh 编写 client 博客的作者