与USB设备通讯 [英] Communication with USB device
问题描述
大家好!
我正在尝试开发与USB设备通信的程序.我刚刚开始使用一些功能,我需要一些帮助.
我写了下面的代码,当我编译它时,没有任何错误,但是当我运行它时,出现了以下错误:
1> Rev 4 .obj:错误LNK2001:未解析的外部符号__RTC_Shutdown
1> Rev 4 .obj:错误LNK2001:未解析的外部符号__RTC_InitBase
我知道上述错误与未链接某些库有关,但我不知道缺少哪些库,因此我认为这与我设置的项目类型有关……!
我设置了Win32控制台应用程序,但是我不确定这是正确的.
我正在阅读Jan Axelson的书,但我认为我需要设置环境的帮助,任何帮助将不胜感激.
#include >< iostream >
#include < fstream >
#include < 字符串 >
#include < Windows.h >
外部 "
{
#include >< >
#include "
#include < setupapi.h >
}
// VOID HidD_GetHidGuid(OUT LPGUID HidGuid);
int main()
{
// GUID HidGuid; //GUID是指示全局变量的数据类型
// HANDLE DeviceInfoSet;
// HidD_GetHidGuid(& HidGuid);
// DeviceInfoSet = SetupDiGetClassDevs(& HidGuid,NULL,NULL,DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);
// std :: cout<< DeviceInfoSet<< std :: endl;
// HidD_GetHidGuid(& HidGuid);
返回 0 ;
}
我还阅读了有关驱动程序的内容,我需要使用免费构建环境"或已检查的构建环境"来构建环境,但是当我只想通过另一个驱动程序与设备通信时,是否需要这样做.我的意思是我不想构建只与设备通信的驱动程序.
无论如何,希望我不要感到困惑.
亲切的问候,
Clio
查看是否有帮助-
http://bytes.com/topic/net/answers/511307-where-rtc-libraries [^ ]
http://social.msdn.microsoft.com/Forums/是/vcgeneral/thread/a8bae441-ea35-4b68-bb4a-ea9b0e497449 [ http://forums.codeguru.com/showthread.php?t=346998 [ ^ ]
我尝试过
在CodeGuru上检查以下旧线程: ^ ]
通过使用以下设置解决了问题:
项目浏览器>设置>连结器>输入>
-其他依赖项:libcp.lib
-忽略所有默认库:否
-忽略特定库:libc.lib
Soren Madsen
Hi guys!!
I''m trying to develop a program that communicates with a USB device. I''ve just started playing around with some functions and I need some help.
I wrote the code bellow and when I compile it, I have no errors but when i run it i get the following errors:
1>Rev 4.obj : error LNK2001: unresolved external symbol __RTC_Shutdown 1>Rev 4.obj : error LNK2001: unresolved external symbol __RTC_InitBase
I know that the above errors are to do with not linking some libraries but I have no clue what ones are missing and so i''m thinking it''s something to do with the type of project i set up...!?
I set up a Win32 Console application but i''m not sure this is right.
I''m reading Jan Axelson''s books but I think I need help setting up the environment, any help would be greatly appreciated.
#include <iostream> #include <fstream> #include <string> #include <Windows.h> extern "C" { #include <hidclass.h> #include "hidsdi.h" #include <setupapi.h> } //VOID HidD_GetHidGuid(OUT LPGUID HidGuid); int main() { //GUID HidGuid; // GUID is a data type that indicates a global variable //HANDLE DeviceInfoSet; //HidD_GetHidGuid(&HidGuid); //DeviceInfoSet = SetupDiGetClassDevs(&HidGuid, NULL, NULL, DIGCF_PRESENT|DIGCF_INTERFACEDEVICE); //std::cout << DeviceInfoSet << std::endl; // HidD_GetHidGuid(&HidGuid); return 0; }
I also read stuff on drivers and that i need to build the environment using "free build environment" or "checked build environment", but do I need to do this when I just want to communicate with a device through another driver. I mean I don''t want to build a driver i just want to communicate with the device.
anyway, hope i''m not being to confusing.
Kind regards,
Clio解决方案See if these help -
http://bytes.com/topic/net/answers/511307-where-rtc-libraries[^]
http://social.msdn.microsoft.com/Forums/is/vcgeneral/thread/a8bae441-ea35-4b68-bb4a-ea9b0e497449[^]
http://forums.codeguru.com/showthread.php?t=346998[^]
I tried a few of those already, any other ideas?
Check this old thread on CodeGuru: http://forums.codeguru.com/showthread.php?t=346998[^]
The problem was solved by using these settings:
Project Explorer > Settings > Linker > Input >
- Additional dependencies: libcp.lib
- Ignore All default libraries : no
- ignore specific library : libc.lib
Soren Madsen
这篇关于与USB设备通讯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!