0

从官方文档中提到 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 towpa_ctrl_open' collect2: error: ld returned 1 exit status Makefile:8: recipe for target 'logging' failed make: *** [logging] Error 1"

4

1 回答 1

0

请看一下在 OpenWrt中创建包。您需要为您的程序创建一个新包,并将该wpa包作为您的包的依赖项,并将该库添加到LDFLAGS您的包 Makefile 中。

于 2017-05-27T22:56:21.920 回答