title: ERROR 2019 Linker Error Visual Studio
body: <p>Hey I hope someone can tell me know to fix this issue I am having i keep getting an error 2019 from Visual studio for the following file. Now most of the functions have been removed so excuse the empty varriables etc.</p>
  
  <p>Error   error LNK2019: unresolved external symbol "void * __cdecl OpenOneDevice(void *,struct _SP_DEVICE_INTERFACE_DATA *,char *)" (?OpenOneDevice@@YAPAXPAXPAU_SP_DEVICE_INTERFACE_DATA@@PAD@Z) referenced in function _wmain  c:\Users\K\documents\visual studio 2010\Projects\test2\test2\test2.obj  test2</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;windows.h&gt;
  #include &lt;setupapi.h&gt;
  
  SP_DEVICE_INTERFACE_DATA deviceInfoData;
  HDEVINFO hwDeviceInfo;
  HANDLE hOut;
  char *devName;
  //
  HANDLE OpenOneDevice(IN HDEVINFO hwDeviceInfo,IN PSP_DEVICE_INTERFACE_DATA DeviceInfoData,IN char *devName);
  //
  HANDLE OpenOneDevice(IN HDEVINFO HardwareDeviceInfo,IN PSP_DEVICE_INTERFACE_DATA DeviceInfoData,IN char *devName) {
      PSP_DEVICE_INTERFACE_DETAIL_DATA functionClassDeviceData = NULL;
      ULONG predictedLength = 0, requiredLength = 0;
      HANDLE hOut = INVALID_HANDLE_VALUE;
  
      SetupDiGetDeviceInterfaceDetail(HardwareDeviceInfo, DeviceInfoData, NULL, 0, &amp;requiredLength, NULL);
  
      predictedLength = requiredLength;
  
      functionClassDeviceData = (PSP_DEVICE_INTERFACE_DETAIL_DATA)malloc(predictedLength);
      if(NULL == functionClassDeviceData) {
          return hOut;
      }
      functionClassDeviceData-&gt;cbSize = sizeof (SP_DEVICE_INTERFACE_DETAIL_DATA);
  
      if (!SetupDiGetDeviceInterfaceDetail(HardwareDeviceInfo, DeviceInfoData, functionClassDeviceData,
          predictedLength, &amp;requiredLength, NULL)) {
          free( functionClassDeviceData );
          return hOut;
      }
  
      //strcpy(devName,functionClassDeviceData-&gt;DevicePath) ;
  
      hOut = CreateFile(functionClassDeviceData-&gt;DevicePath, GENERIC_READ | GENERIC_WRITE,
          FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
  
      free(functionClassDeviceData);
      return hOut;
  }
  
  
  // 
  int _tmain(int argc, _TCHAR* argv[])
  {
  
  
  
      hOut = OpenOneDevice (hwDeviceInfo, &amp;deviceInfoData, devName);
      if(hOut != INVALID_HANDLE_VALUE) 
          {
              // error report
          }
      return 0;
  }
  </code></pre>
  
  <p>Been driving me mad for hours. Any help appreciated.</p>
  
  <p>SOLVED THANKS TO CHRIS :-)</p>
  
  <p>Add #pragma comment (lib, "Setupapi.lib")</p>
  
  <p>Thanks</p>