0
#include"stdafx.h"
#include <windows.h>
#include <iphlpapi.h>
#include <stdio.h>

int main() {

      IP_ADAPTER_INFO *info = NULL, *pos;
      DWORD size = 0;

      GetAdaptersInfo(info, &size);

      info = (IP_ADAPTER_INFO *)malloc(size);

      GetAdaptersInfo(info, &size);

      for (pos = info; pos != NULL; pos = pos->Next) {
              printf("\n%s\n\t", pos->Description);
              printf("%2.2x", pos->Address[0]);
              for (int i = 1; i<pos->AddressLength; i++)
                    printf(":%2.2x", pos->Address[i]);
      }

      free(info);
      return 0;
}

i have done this program and an error

"error LNK2019: unresolved external symbol _GetAdaptersInfo@8 referenced in function _main"

is displaying. What should i do ?

  • 2
    Ensuring the library that provides this function will assist in your linking woes. [See the bottom of the documentation](https://msdn.microsoft.com/en-us/library/windows/desktop/aa365917(v=vs.85).aspx) for the header/library info, and make sure the specified lib is in your linked-libraries. Consult your toolchain documentation for where to put that library reference in your configuration. – WhozCraig Aug 17 '16 at 04:53
  • Your project needs to link to `Iphlpapi.lib`. – Remy Lebeau Aug 17 '16 at 05:21

0 Answers0