Hello,
I am trying to make a C++ project for Visual Studio 2019 to open and monitor CAN message from USB to CAN Compact V2.
I did check SDK and C++ design guide but this simple code gives error below.
"Error LNK2019 unresolved external symbol VciGetDeviceManager referenced in function “long __cdecl SelectDevice(int)” (?SelectDevice@@YAJH@Z) usbcan_cpp
"
HRESULT SelectDevice(BOOL fUserSelect)
{
HRESULT hResult = 0; // error code
if (fUserSelect == FALSE)
{
IVciDeviceManager* pDevMgr = 0; // device manager
IVciEnumDevice* pEnum = 0; // enumerator handle
VCIDEVICEINFO sInfo; // device info
hResult = VciGetDeviceManager(&pDevMgr);
if (hResult == VCI_OK)
{
hResult = pDevMgr->EnumDevices(&pEnum);
}
//
// retrieve information about the first
// device within the device list
//
if (hResult == VCI_OK)
{
hResult = pEnum->Next(1, &sInfo, NULL);
//
// close the device list (no longer needed)
//
pEnum->Release();
pEnum = NULL;
}
//
// open the first device via device manager and get the bal object
//
if (hResult == VCI_OK)
{
IVciDevice* pDevice;
hResult = pDevMgr->OpenDevice(sInfo.VciObjectId, &pDevice);
if (hResult == VCI_OK)
{
hResult = pDevice->OpenComponent(CLSID_VCIBAL, IID_IBalObject, (void**)&pBalObject);
pDevice->Release();
}
}
//
// always select controller 0
//
lBusCtlNo = 0;
//
// close device manager
//
if (pDevMgr)
{
pDevMgr->Release();
pDevMgr = NULL;
}
}
else
{
//
// open a device selected by the user
//
//hResult = SocketSelectDlg(NULL, VCI_BUS_CAN, &pBalObject, &lSocketNo, &lBusCtlNo);
}
//DisplayError(NULL, hResult);
return hResult;
}
I tried to import everything in the sample sdk and copied above piece of code.
Any solutions or other example code that I can try?