I have been playing around with wlanapi in windows. I did not have any problem compiling or running until I tried using the function WlanScan. Then I was unable to compile due to "WlanScan" not being declared in the scope. I wrote a really short program illustrating this using two functions: WlanOpenHandle that works and WlanScan which doesn't.
#include <windows.h>
#include <wlanapi.h>
int main()
{
HANDLE hClient;
WlanOpenHandle(2, 0, 0, &hClient);
WlanScan(hClient, 0, 0, 0, 0);
}
Compiling that single file like this:
g++ main.cpp -lwlanapi
Results in this error:
main.cpp: In function 'int main()':
main.cpp:9:30: error: 'WlanScan' was not declared in this scope
WlanScan(hClient, 0, 0, 0, 0);
^
What could be the cause of this? I've been able to use a handful of functions from the wlanapi. I am on Windows 7 compiling with minGW.
EDIT: In accordance to what u/ IInspectable said, I changed the command used to compile to:
g++ -D_WIN32_WINNT=_WIN32_WINNT_WIN7 main.cpp -lwlanapi
And it worked!