2017-05-25 123 views
0

从官方文档中引用wpa_ctrl.c:“外部程序可以将此文件链接到它们”中,如何执行此操作?如何通过将这些文件包含在我的项目目录中来使用wpa_ctrl.h中的API

我在我的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; 
} 

//错误: 错误: “/tmp/ccnSzmjE.o:在功能main': hostap_wpa_client.c:(.text+0xf): undefined reference to wpa_ctrl_open” collect2:错误:LD返回1退出状态 生成文件:8 :目标'日志记录'的配方失败 make:*** [日志记录]错误1“

回答

0

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

相关问题