0

I am getting this error and I don't know why. I would like to create a library to operate with WinPcap, and public some of their functions. I attach part of my code:

class WinPcap
{
private:
    bool discoverDone;
    std::list<Device> discoverDeviceList;    
    void Listen();    

public:
    WinPcap();
    ~WinPcap();

    //This process is bloking, remain throw it in a different thread.
    std::list<Device> Discover();

    static void GetHostMacAddress(UINT8* macAddress, int pointerSize);
};

And now I found this method to get the host mac address in c++:

void WinPcap::GetHostMacAddress(UINT8* macAddress, int pointerSize)
{
    IP_ADAPTER_INFO AdapterInfo[16];       // Allocate information for up to 16 NICs
    DWORD dwBufLen = sizeof(AdapterInfo);  // Save memory size of buffer

    DWORD dwStatus = GetAdaptersInfo(      // Call GetAdapterInfo
        AdapterInfo,                 // [out] buffer to receive data
        &dwBufLen);                  // [in] size of receive data buffer

    PIP_ADAPTER_INFO pAdapterInfo = AdapterInfo; // Contains pointer to current adapter info
}

I am getting the error in that function. But if I comment the GetAdaptersInfo function, I don't get it.

Why is this happening?

ars1614
  • 69
  • 1
  • 11
  • Did you link your program with the winsock library? – πάντα ῥεῖ Nov 27 '15 at 13:10
  • please post the full error message. It isn't clear which symbol is unresolved (probably GetAdaptersInfo, but message would help). – Zdeslav Vojkovic Nov 27 '15 at 13:11
  • BTW, `GetAdaptersInfo` is Windows API call, and your question is tagged as `osx`. You might want to check this: http://stackoverflow.com/questions/1126790/how-to-get-network-adapter-stats-in-linux-mac-osx – Zdeslav Vojkovic Nov 27 '15 at 13:13
  • Yes, sorry, I don't know how it got to it. It is WinApi yes. – ars1614 Nov 27 '15 at 15:08
  • Possible duplicate of [What is an undefined reference/unresolved external symbol error and how do I fix it?](http://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – IInspectable Nov 27 '15 at 23:00

1 Answers1

1

I am slightly confused as your question is tagged as osx, but GetAdaptersInfo is Windows API call and you seem to be using Visual Studio.

If the question is mistakenly tagged as osx, you have probably forgot to link your program to iphlpapi.lib

If it is really meant to work on OS X, you might want to check these links:

Community
  • 1
  • 1
Zdeslav Vojkovic
  • 14,391
  • 32
  • 45