Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How To Compile C++ Code that has a 'wlanapi.h' and 'windows.h' dependency

I am modifying an open source code that scans for Wireless signals in the vicinity. The program code goes like this:

#pragma comment(lib, "wlanapi.lib")

#include <stdio.h>
#include <windows.h>
#include <wlanapi.h>

VOID WlanNotification(WLAN_NOTIFICATION_DATA *wlanNotifData,VOID *p)
{
    if(wlanNotifData->NotificationCode == wlan_notification_acm_scan_complete)
    {
        bWait = false;
    }
    else if(wlanNotifData->NotificationCode == wlan_notification_acm_scan_fail)
    {
        printf("Scanning failed with error: %x\n", wlanNotifData->pData);
        bWait = false;

......

I wanted to know how I can compile the source code that has wlanapi.h and windows.h dependency?

Please note that I want this code to run on Windows (Not Linux). I am coding a Tool for simple windows users that would diagnose their Wifi security for them. The first step is to sense the nearest WiFi APs and their respective Encryption Types. I just want to know how I can compile this code for windows platform that has a 'windows.h' or 'wlanapi.h' dependency, in the easiest possible way.

like image 955
learnerX Avatar asked Sep 15 '25 01:09

learnerX


1 Answers

It's important to understand that C and C++ are portable languages, but that doesn't mean that API's are the same for different OS's - and this is a good example of that.

The simple solution to your problem is probably to find another source that is already working on a Linux platform. This seems to be a decent resource: http://tuxmobil.org/linux_wireless_sniffer.html

If your goal is to make this code run on Linux, then you will need to find the corresponding Linux interfaces. There is a question about this here: Wireless API for Linux in C or Java

Unfortunately, that's not a straight "plug-in" compatible interface for the Windows code, so you will have to make some pretty significant modifications to the code (or build a compatibility library that emulates the wlanapi.h functionality, but my rough estimate is that this is not easier!)

like image 152
Mats Petersson Avatar answered Sep 17 '25 14:09

Mats Petersson