python - 构建 Cython-HIDapi Python 2.7

标签 python cython hid libusb

我在构建 Cython 时遇到了很多问题在我的 Windows 虚拟机中。我在 OS X 中没有遇到任何问题,但它真的开始让我感到沮丧......

>>setup.py 全新安装

running clean
removing 'build\temp.win-amd64-2.7' (and everything under it)
removing 'build'
running install
running build
running build_ext
skipping 'hid.c' Cython extension (up-to-date)
building 'hid' extension
creating build
creating build\temp.win-amd64-2.7
creating build\temp.win-amd64-2.7\Release
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python27\include -IC:\Python27\PC /Tchid.c /Fobuild\temp.win-amd64-2.7\Release\hid.obj
hid.c
c:\python27\include\pymath.h(22) : warning C4273: 'round' : inconsistent dll linkage
        C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\math.h(516) : see previous definition of 'round'
hid.c(801) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python27\include -IC:\Python27\PC /Tchid-libus
b.c /Fobuild\temp.win-amd64-2.7\Release\hid-libusb.obj
hid-libusb.c
hid-libusb.c(52) : fatal error C1083: Cannot open include file: 'iconv.h': No such file or directory
error: command '"C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\BIN\amd64\cl.exe"' failed with exit status 2

我在计算机上找不到任何名为“iconv.h”的 header 。如果这不包含在 VC++ 中2013年了,我怎样才能让它发挥作用?

使用>>setup-windows.py clean install后:

running clean
removing 'build\temp.win-amd64-2.7' (and everything under it)
removing 'build'
running install
running build
running build_ext
skipping 'hid.c' Cython extension (up-to-date)
building 'hid' extension
creating build
creating build\temp.win-amd64-2.7
creating build\temp.win-amd64-2.7\Release
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\cl.exe /c /nolog
o /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python27\include -IC:\Python27\PC /Tchid.c /Fob
uild\temp.win-amd64-2.7\Release\hid.obj
hid.c
hid.c(801) : warning C4267: '=' : conversion from 'size_t' to 'int', possible lo
ss of data
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\cl.exe /c /nolog
o /Ox /MD /W3 /GS- /DNDEBUG -IC:\Python27\include -IC:\Python27\PC /Tchid-window
s.c /Fobuild\temp.win-amd64-2.7\Release\hid-windows.obj
hid-windows.c
hid-windows.c(205) : error C2275: 'GUID' : illegal use of this type as an expres
sion
        C:\Program Files\\Microsoft SDKs\Windows\v6.0A\include\guiddef.h(27) : s
ee declaration of 'GUID'
hid-windows.c(205) : error C2146: syntax error : missing ';' before identifier '
InterfaceClassGuid'
hid-windows.c(205) : error C2065: 'InterfaceClassGuid' : undeclared identifier
hid-windows.c(205) : error C2059: syntax error : '{'
hid-windows.c(206) : error C2275: 'SP_DEVINFO_DATA' : illegal use of this type a
s an expression
        C:\Program Files\\Microsoft SDKs\Windows\v6.0A\include\setupapi.h(708) :
 see declaration of 'SP_DEVINFO_DATA'
hid-windows.c(206) : error C2146: syntax error : missing ';' before identifier '
devinfo_data'
hid-windows.c(206) : error C2065: 'devinfo_data' : undeclared identifier
hid-windows.c(207) : error C2275: 'SP_DEVICE_INTERFACE_DATA' : illegal use of th
is type as an expression
        C:\Program Files\\Microsoft SDKs\Windows\v6.0A\include\setupapi.h(720) :
 see declaration of 'SP_DEVICE_INTERFACE_DATA'
hid-windows.c(207) : error C2146: syntax error : missing ';' before identifier '
device_interface_data'
hid-windows.c(207) : error C2065: 'device_interface_data' : undeclared identifie
r
hid-windows.c(208) : error C2275: 'SP_DEVICE_INTERFACE_DETAIL_DATA_A' : illegal
use of this type as an expression
        C:\Program Files\\Microsoft SDKs\Windows\v6.0A\include\setupapi.h(742) :
 see declaration of 'SP_DEVICE_INTERFACE_DETAIL_DATA_A'
hid-windows.c(208) : error C2065: 'device_interface_detail_data' : undeclared id
entifier
hid-windows.c(209) : error C2275: 'HDEVINFO' : illegal use of this type as an ex
pression
        C:\Program Files\\Microsoft SDKs\Windows\v6.0A\include\setupapi.h(697) :
 see declaration of 'HDEVINFO'
hid-windows.c(209) : error C2146: syntax error : missing ';' before identifier '
device_info_set'
hid-windows.c(209) : error C2065: 'device_info_set' : undeclared identifier
hid-windows.c(209) : warning C4047: '=' : 'int' differs in levels of indirection
 from 'HANDLE'
hid-windows.c(212) : error C2065: 'devinfo_data' : undeclared identifier
hid-windows.c(212) : error C2224: left of '.cbSize' must have struct/union type
hid-windows.c(213) : error C2065: 'device_interface_data' : undeclared identifie
r
hid-windows.c(213) : error C2224: left of '.cbSize' must have struct/union type
hid-windows.c(217) : error C2065: 'device_info_set' : undeclared identifier
hid-windows.c(217) : error C2065: 'InterfaceClassGuid' : undeclared identifier
hid-windows.c(217) : warning C4133: 'function' : incompatible types - from 'int
*' to 'const GUID *'
hid-windows.c(217) : warning C4047: '=' : 'int' differs in levels of indirection
 from 'HDEVINFO'
hid-windows.c(220) : error C2143: syntax error : missing ';' before 'type'
hid-windows.c(225) : error C2065: 'device_info_set' : undeclared identifier
hid-windows.c(225) : warning C4022: 'SetupDiEnumDeviceInterfaces' : pointer mism
atch for actual parameter 1
hid-windows.c(227) : error C2065: 'InterfaceClassGuid' : undeclared identifier
hid-windows.c(227) : warning C4133: 'function' : incompatible types - from 'int
*' to 'const GUID *'
hid-windows.c(228) : error C2065: 'device_index' : undeclared identifier
hid-windows.c(229) : error C2065: 'device_interface_data' : undeclared identifie
r
hid-windows.c(229) : warning C4133: 'function' : incompatible types - from 'int
*' to 'PSP_DEVICE_INTERFACE_DATA'
hid-windows.c(240) : error C2065: 'device_info_set' : undeclared identifier
hid-windows.c(240) : warning C4022: 'SetupDiGetDeviceInterfaceDetailA' : pointer
 mismatch for actual parameter 1
hid-windows.c(241) : error C2065: 'device_interface_data' : undeclared identifie
r
hid-windows.c(241) : warning C4133: 'function' : incompatible types - from 'int
*' to 'PSP_DEVICE_INTERFACE_DATA'
hid-windows.c(248) : error C2065: 'device_interface_detail_data' : undeclared id
entifier
hid-windows.c(248) : warning C4047: '=' : 'int' differs in levels of indirection
 from 'SP_DEVICE_INTERFACE_DETAIL_DATA_A *'
hid-windows.c(249) : error C2065: 'device_interface_detail_data' : undeclared id
entifier
hid-windows.c(249) : error C2223: left of '->cbSize' must point to struct/union
hid-windows.c(254) : error C2065: 'device_info_set' : undeclared identifier
hid-windows.c(254) : warning C4022: 'SetupDiGetDeviceInterfaceDetailA' : pointer
 mismatch for actual parameter 1
hid-windows.c(255) : error C2065: 'device_interface_data' : undeclared identifie
r
hid-windows.c(255) : warning C4133: 'function' : incompatible types - from 'int
*' to 'PSP_DEVICE_INTERFACE_DATA'
hid-windows.c(256) : error C2065: 'device_interface_detail_data' : undeclared id
entifier
hid-windows.c(256) : warning C4047: 'function' : 'PSP_DEVICE_INTERFACE_DETAIL_DA
TA_A' differs in levels of indirection from 'int'
hid-windows.c(256) : warning C4024: 'SetupDiGetDeviceInterfaceDetailA' : differe
nt types for formal and actual parameter 3
hid-windows.c(270) : error C2065: 'device_interface_detail_data' : undeclared id
entifier
hid-windows.c(270) : error C2223: left of '->DevicePath' must point to struct/un
ion
hid-windows.c(271) : warning C4047: 'function' : 'LPCSTR' differs in levels of i
ndirection from 'unsigned long'
hid-windows.c(271) : warning C4024: 'CreateFileA' : different types for formal a
nd actual parameter 1
hid-windows.c(273) : warning C4047: 'function' : 'DWORD' differs in levels of in
direction from 'void *'
hid-windows.c(273) : warning C4024: 'CreateFileA' : different types for formal a
nd actual parameter 3
hid-windows.c(274) : warning C4047: 'function' : 'LPSECURITY_ATTRIBUTES' differs
 in levels of indirection from 'int'
hid-windows.c(274) : warning C4024: 'CreateFileA' : different types for formal a
nd actual parameter 4
hid-windows.c(276) : error C2198: 'CreateFileA' : too few arguments for call
hid-windows.c(287) : error C2275: 'HIDD_ATTRIBUTES' : illegal use of this type a
s an expression
        hid-windows.c(79) : see declaration of 'HIDD_ATTRIBUTES'
hid-windows.c(287) : error C2146: syntax error : missing ';' before identifier '
attrib'
hid-windows.c(287) : error C2065: 'attrib' : undeclared identifier
hid-windows.c(288) : error C2065: 'attrib' : undeclared identifier
hid-windows.c(288) : error C2224: left of '.Size' must have struct/union type
hid-windows.c(289) : error C2065: 'attrib' : undeclared identifier
hid-windows.c(289) : warning C4133: 'function' : incompatible types - from 'int
*' to 'PHIDD_ATTRIBUTES'
hid-windows.c(295) : error C2065: 'attrib' : undeclared identifier
hid-windows.c(295) : error C2224: left of '.VendorID' must have struct/union typ
e
hid-windows.c(295) : error C2065: 'attrib' : undeclared identifier
hid-windows.c(295) : error C2224: left of '.ProductID' must have struct/union ty
pe
hid-windows.c(331) : error C2065: 'device_interface_detail_data' : undeclared id
entifier
hid-windows.c(331) : error C2223: left of '->DevicePath' must point to struct/un
ion
hid-windows.c(363) : error C2065: 'attrib' : undeclared identifier
hid-windows.c(363) : error C2224: left of '.VendorID' must have struct/union typ
e
hid-windows.c(364) : error C2065: 'attrib' : undeclared identifier
hid-windows.c(364) : error C2224: left of '.ProductID' must have struct/union ty
pe
hid-windows.c(367) : error C2065: 'attrib' : undeclared identifier
hid-windows.c(367) : error C2224: left of '.VersionNumber' must have struct/unio
n type
hid-windows.c(377) : error C2065: 'device_interface_detail_data' : undeclared id
entifier
hid-windows.c(377) : warning C4022: 'free' : pointer mismatch for actual paramet
er 1
hid-windows.c(379) : error C2065: 'device_index' : undeclared identifier
hid-windows.c(384) : error C2065: 'device_info_set' : undeclared identifier
hid-windows.c(384) : warning C4022: 'SetupDiDestroyDeviceInfoList' : pointer mis
match for actual parameter 1
hid-windows.c(505) : warning C4267: 'function' : conversion from 'size_t' to 'DW
ORD', possible loss of data
hid-windows.c(536) : error C2275: 'OVERLAPPED' : illegal use of this type as an
expression
        C:\Program Files\\Microsoft SDKs\Windows\v6.0A\include\winbase.h(250) :
see declaration of 'OVERLAPPED'
hid-windows.c(536) : error C2146: syntax error : missing ';' before identifier '
ol'
hid-windows.c(536) : error C2065: 'ol' : undeclared identifier
hid-windows.c(537) : error C2065: 'ol' : undeclared identifier
hid-windows.c(537) : error C2065: 'ol' : undeclared identifier
hid-windows.c(538) : error C2065: 'ol' : undeclared identifier
hid-windows.c(538) : error C2224: left of '.hEvent' must have struct/union type
hid-windows.c(544) : warning C4267: 'function' : conversion from 'size_t' to 'DW
ORD', possible loss of data
hid-windows.c(544) : error C2065: 'ol' : undeclared identifier
hid-windows.c(544) : warning C4133: 'function' : incompatible types - from 'int
*' to 'LPOVERLAPPED'
hid-windows.c(571) : error C2065: 'ol' : undeclared identifier
hid-windows.c(571) : warning C4133: 'function' : incompatible types - from 'int
*' to 'LPOVERLAPPED'
hid-windows.c(603) : warning C4267: 'function' : conversion from 'size_t' to 'UL
ONG', possible loss of data
hid-windows.c(609) : warning C4267: 'return' : conversion from 'size_t' to 'int'
, possible loss of data
hid-windows.c(631) : warning C4267: 'function' : conversion from 'size_t' to 'DW
ORD', possible loss of data
hid-windows.c(632) : warning C4267: 'function' : conversion from 'size_t' to 'DW
ORD', possible loss of data
hid-windows.c(668) : warning C4267: 'function' : conversion from 'size_t' to 'UL
ONG', possible loss of data
hid-windows.c(681) : warning C4267: 'function' : conversion from 'size_t' to 'UL
ONG', possible loss of data
hid-windows.c(694) : warning C4267: 'function' : conversion from 'size_t' to 'UL
ONG', possible loss of data
hid-windows.c(707) : warning C4267: 'function' : conversion from 'size_t' to 'UL
ONG', possible loss of data
error: command '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64
\cl.exe"' failed with exit status 2

最佳答案

该项目包含单独的 setup-windows.py setup script .

使用该脚本而不是setup.py

python setup-windows.py install

关于python - 构建 Cython-HIDapi Python 2.7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20876393/

相关文章:

hid - 在 VC++ 中使用 PID 和 VID 函数检测 USB 设备的问题

python - 使用 Python 创建 MySQL 游标函数

Python - 正则表达式 - 特殊字符和 ñ

python - 如何获取自定义间隔中的最后一个日期? - Pandas

python - 在 cython 类中包装一个预初始化的指针

python - Cython 与 Python 3.3

python - 将具有属性的 python 对象转换为字典

linux - 在 Linux 上使用 libudev 阻止读取的问题

java - Archos a28 : Read and Write directly to device 上的 USB 输入设备

python - 相互依赖的默认参数