从官方文档中提到 wpa_ctrl.c: "External programs can link this file into them" ,如何做到这一点?
我的 openwrt 构建目录中有“hostapd-full”。其中一切都很好(Wpa ctrl 和 wpa cli)
我必须编写一个在这个“hostapd-full”目录之外的示例程序才能使用 wpa_cli/ctrl API。
代码:
#include "includes.h"
#include <dirent.h>
#include "wpa_ctrl.h"
#include "common.h"
static struct wpa_ctrl *ctrl_conn;
static const char *ctrl_iface_dir = "/var/run/wpa_supplicant";
int main()
{
ctrl_conn = wpa_ctrl_open(ctrl_iface_dir);
if (!ctrl_conn){
printf("Could not get ctrl interface!\n");
return -1;
}
return 0;
}
//error: Error: "/tmp/ccnSzmjE.o: In function main':
hostap_wpa_client.c:(.text+0xf): undefined reference to
wpa_ctrl_open' collect2: error: ld returned 1 exit status Makefile:8: recipe for target 'logging' failed make: *** [logging] Error 1"