一。编译AdbWinApi:
(a) error C2664: 'CreateFileA' : cannot convert parameter 1 from 'const unsigned short *' to 'const char *'
解决办法:将项目的字符集设置成unicode:
-------------------------------------------------------------------------------------------------------------------------------------------------------
.
(b).>d:\work\project\adb_dev\api\adb_api_instance.h(103): error C2146: 语法错误: 缺少“;”(在标识符“instance_handle_”的前面)
1>d:\work\project\adb_dev\api\adb_api_instance.h(103): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
1>d:\work\project\adb_dev\api\adb_api_instance.h(110): error C2065: “ADBAPIINSTANCEHANDLE”: 未声明的标识符
1>d:\work\project\adb_dev\api\adb_api_instance.h(110): error C2923: “std::map”: 对于参数“_Kty”,“ADBAPIINSTANCEHANDLE”不是有效的 模板 类型变量
1>d:\work\project\adb_dev\api\adb_api_instance.cpp(39): error C2065: “instance_handle_”: 未声明的标识符
1>d:\work\project\adb_dev\api\adb_api_instance.cpp(40): error C2061: 语法错误: 标识符“ADBAPIINSTANCEHANDLE”
解决办法:在文件中添加typedef void* ADBAPIINSTANCEHANDLE;
----------------------------------------------------------------------------------------------------------------------------------------------------------------
adb_helper_routines.obj : error LNK2019: 无法解析的外部符号 __imp__SetupDiDestroyDeviceInfoList@4,该符号在函数 "bool __cdecl EnumerateDeviceInterfaces(struct _GUID,unsigned long,bool,bool,class std::vector<class AdbInstanceEnumEntry,class std::allocator<class AdbInstanceEnumEntry> > *)" (?EnumerateDeviceInterfaces@@YA_NU_GUID@@K_N1PAV?$vector@VAdbInstanceEnumEntry@@V?$allocator@VAdbInstanceEnumEntry@@@std@@@std@@@Z) 中被引用
1>adb_helper_routines.obj : error LNK2019: 无法解析的外部符号 __imp__SetupDiEnumDeviceInterfaces@20,该符号在函数 "bool __cdecl EnumerateDeviceInterfaces(void *,struct _GUID,bool,bool,class std::vector<class AdbInstanceEnumEntry,class std::allocator<class AdbInstanceEnumEntry> > *)" (?EnumerateDeviceInterfaces@@YA_NPAXU_GUID@@_N2PAV?$vector@VAdbInstanceEnumEntry@@V?$allocator@VAdbInstanceEnumEntry@@@std@@@std@@@Z) 中被引用
1>adb_helper_routines.obj : error LNK2019: 无法解析的外部符号 __imp__SetupDiGetDeviceInterfaceDetailW@24,该符号在函数 "bool __cdecl GetUsbDeviceDetails(void *,struct _SP_DEVICE_INTERFACE_DATA *,struct _SP_DEVICE_INTERFACE_DETAIL_DATA_W * *)" (?GetUsbDeviceDetails@@YA_NPAXPAU_SP_DEVICE_INTERFACE_DATA@@PAPAU_SP_DEVICE_INTERFACE_DETAIL_DATA_W@@@Z) 中被引用
1>adb_helper_routines.obj : error LNK2019: 无法解析的外部符号 __imp__SetupDiGetClassDevsW@16,该符号在函数 "bool __cdecl EnumerateDeviceInterfaces(struct _GUID,unsigned long,bool,bool,class std::vector<class AdbInstanceEnumEntry,class std::allocator<class AdbInstanceEnumEntry> > *)" (?EnumerateDeviceInterfaces@@YA_NU_GUID@@K_N1PAV?$vector@VAdbInstanceEnumEntry@@V?$allocator@VAdbInstanceEnumEntry@@@std@@@std@@
解决办法:在依赖项中添加setupapi.lib
二.AdbWinUsbApi编译出错:
(a)
1>d:\work\project\adb_dev\winusb\adb_winusb_interface.h(170): error C2146: 语法错误: 缺少“;”(在标识符“winusb_handle”的前面)
1>d:\work\project\adb_dev\winusb\adb_winusb_interface.h(170): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
解决办法:
stdafx.h的修改:
将win的版本号改成0x602
#ifndef _WIN32_WINNT // Allow use of features specific to Windows NT 4 or later.
//#define _WIN32_WINNT 0x0500 // Change this to the appropriate value to target Windows 2000 or later.
#define _WIN32_WINNT 0x0602
#endif
#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
//#define _WIN32_WINDOWS 0x0500 // Change this to the appropriate value to target Windows Me or later.
#define _WIN32_WINDOWS 0x0602
#endif