ERROR 2019 Linker Error Visual Studio
Posted
by
Corrie Duck
on Stack Overflow
See other posts from Stack Overflow
or by Corrie Duck
Published on 2012-09-19T03:01:26Z
Indexed on
2012/09/19
3:38 UTC
Read the original article
Hit count: 228
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.
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
#include "stdafx.h"
#include <windows.h>
#include <setupapi.h>
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, &requiredLength, NULL);
predictedLength = requiredLength;
functionClassDeviceData = (PSP_DEVICE_INTERFACE_DETAIL_DATA)malloc(predictedLength);
if(NULL == functionClassDeviceData) {
return hOut;
}
functionClassDeviceData->cbSize = sizeof (SP_DEVICE_INTERFACE_DETAIL_DATA);
if (!SetupDiGetDeviceInterfaceDetail(HardwareDeviceInfo, DeviceInfoData, functionClassDeviceData,
predictedLength, &requiredLength, NULL)) {
free( functionClassDeviceData );
return hOut;
}
//strcpy(devName,functionClassDeviceData->DevicePath) ;
hOut = CreateFile(functionClassDeviceData->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, &deviceInfoData, devName);
if(hOut != INVALID_HANDLE_VALUE)
{
// error report
}
return 0;
}
Been driving me mad for hours. Any help appreciated.
SOLVED THANKS TO CHRIS :-)
Add #pragma comment (lib, "Setupapi.lib")
Thanks
© Stack Overflow or respective owner