how to make use of the API in wpa_ctrl.h by just including these files in my project directory

868 Views Asked by At

From the official doc referring to wpa_ctrl.c: "External programs can link this file into them" , how to do this?

I have the "hostapd-full" in my openwrt build directory. in which all are fine (Wpa ctrl and wpa cli)

I have to write a sample program which is out side of this "hostapd-full" directory to use wpa_cli/ctrl API.

Code:

#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"

1

There are 1 best solutions below

0
On

Please take a look at creating packages in OpenWrt. You need to create a new package for your program and make the wpa package as a dependency for your package and add the library to the LDFLAGS in your package Makefile.