正在获取lnk2019 VC++

Getting lnk2019 VC++

本文关键字:VC++ lnk2019 获取      更新时间:2023-10-16

我收到这个错误,我不知道为什么。我想创建一个库来操作WinPcap,并公开它们的一些函数。我附上我的部分代码:

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);
};

现在我找到了这个方法来获取c++中的主机mac地址:

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
}

我得到了那个函数中的错误。但是如果我评论GetAdaptersInfo函数,我就不明白了

为什么会发生这种情况?

我有点困惑,因为您的问题被标记为osx,但GetAdaptersInfo是Windows API调用,您似乎正在使用Visual Studio。

如果问题被错误地标记为osx,您可能忘记将程序链接到iphlpapi.lib

如果它真的打算在OS X上工作,你可能想检查以下链接:

  • 如何在linux/MacOSX中获取网络适配器统计信息
  • http://wxwidgets.info/cross-platform-way-of-obtaining-mac-address-of-your-machine/