Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Qt 为Windows构建SIP和PyGlobalShortcut_Qt_Python 2.7_Mingw_Cross Compiling_Mxe - Fatal编程技术网

Qt 为Windows构建SIP和PyGlobalShortcut

Qt 为Windows构建SIP和PyGlobalShortcut,qt,python-2.7,mingw,cross-compiling,mxe,Qt,Python 2.7,Mingw,Cross Compiling,Mxe,我正在Ubuntu下编写一个Python2.7/PyQt4程序,但该应用程序将部署在Windows平台上。其中一个功能是,应用程序应捕获多个按键(例如“Alt+A”),即使它未处于焦点/最小化状态。为此,我使用了一个Python/SIP包装器。按照手册,我安装了Qt4+并运行了pip install PyGlobalShortcut命令,该命令自动编译并安装了libqxt库和Python包装器。这是完美的 在Windows下本地构建 然而,我在Windows下安装PyGlobalShortcut

我正在Ubuntu下编写一个Python2.7/PyQt4程序,但该应用程序将部署在Windows平台上。其中一个功能是,应用程序应捕获多个按键(例如“Alt+A”),即使它未处于焦点/最小化状态。为此,我使用了一个Python/SIP包装器。按照手册,我安装了Qt4+并运行了
pip install PyGlobalShortcut
命令,该命令自动编译并安装了libqxt库和Python包装器。这是完美的

在Windows下本地构建 然而,我在Windows下安装PyGlobalShortcut时遇到了麻烦。包的二进制发行版已经过时,这意味着我必须自己编译它。我必须安装Qt4+MinGW并调整
$PATH
,这不是问题。下一步是获取SIP,不幸的是,Py2.7没有以二进制形式提供SIP。我获得了SIP的源代码,但无法构建它:

sip-4.17 $ python configure.py --platform win32-g++
sip-4.17 $ make
make
调用
mingw32 make
,该
立即返回一个错误,该错误无法找到
MSVCR80.dll
。我在谷歌上搜索了一下,它似乎是微软VisualStudio的一个组件或者类似的东西,但是它和MinGW有什么关系呢?我找不到任何提供这个dll或解释如何获取它的官方网站

Linux下的交叉编译 我还认为我可以在Linux机器上使用交叉编译PyGlobalShortcut。我也没有做到这一点。 我用它作为指导。我得到了MXE,交叉编译了Qt4,并用
wine
检查它是否有效。然后我将
/usr/bin
/usr/i686-w64-mingw32.static/qt/bin
包含到
$PATH
中,并尝试交叉编译windows的SIP。它失败了,因为MaFixFror调用了本地Linux“代码> G++<代码>,而不是针对C++编译器的<代码> MXE >:

sip-4.17 $ python configure.py --platform win32-g++
sip-4.17 $ make
make[1]: Entering directory `/home/ximeg/dev/sip-4.17/sipgen'
gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o main.o main.c
gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o transform.o transform.c
gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o gencode.o gencode.c
gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o extracts.o extracts.c
gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o export.o export.c
gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o heap.o heap.c
gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o parser.o parser.c
gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o lexer.o lexer.c
g++ -mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -Wl,-s -o sip main.o transform.o gencode.o extracts.o export.o heap.o parser.o lexer.o 
main.o: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
make[1]: *** [sip] Error 1
make[1]: Leaving directory `/home/ximeg/dev/sip-4.17/sipgen'
make: *** [all] Error 2
因此,我在
/usr/bin
下将编译器和链接器进行了符号链接,即
i686-w64-mingw32.static-g++
g++
等。这很有帮助,但现在
g++
需要Python库和头。它在
/usr/include/python2.7
下查找它们,但它们是为linux编译的,因此无法链接到windows二进制文件

sip-4.17 $ make
make[1]: Entering directory `/home/ximeg/dev/sip-4.17/sipgen'
gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -o main.o main.c
...
g++ -mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -Wl,-subsystem,console -Wl,-s -o sip main.o transform.o gencode.o extracts.o export.o heap.o parser.o lexer.o 
make[1]: Leaving directory `/home/ximeg/dev/sip-4.17/sipgen'
make[1]: Entering directory `/home/ximeg/dev/sip-4.17/siplib'
gcc -c -O2 -w -DNDEBUG -DUNICODE -DQT_LARGEFILE_SUPPORT -I. -I/usr/include/python2.7 -o siplib.o siplib.c
In file included from /usr/include/python2.7/Python.h:8:0,
                 from siplib.c:20:
/usr/include/python2.7/pyconfig.h:78:3: error: #error unknown multiarch location for pyconfig.h
 # error unknown multiarch location for pyconfig.h
   ^
In file included from /usr/include/python2.7/pyport.h:4:0,
                 from /usr/include/python2.7/Python.h:58,
                 from siplib.c:20:
/usr/include/python2.7/pyconfig.h:78:3: error: #error unknown multiarch location for pyconfig.h
 # error unknown multiarch location for pyconfig.h
   ^
In file included from /usr/include/python2.7/pymath.h:4:0,
                 from /usr/include/python2.7/Python.h:77,
                 from siplib.c:20:
/usr/include/python2.7/pyconfig.h:78:3: error: #error unknown multiarch location for pyconfig.h
 # error unknown multiarch location for pyconfig.h
   ^
siplib.c: In function 'wrapInstance':
siplib.c:1342:27: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'addr'
     unsigned PY_LONG_LONG addr;
                           ^
siplib.c:1342:27: error: 'addr' undeclared (first use in this function)
siplib.c:1342:27: note: each undeclared identifier is reported only once for each function it appears in
siplib.c: In function 'parsePass1':
siplib.c:4488:9: error: expected ';' before 'case'
         case 'c':
         ^
siplib.c:4526:9: error: expected ';' before 'case'
         case 'b':
         ^
make[1]: *** [siplib.o] Error 1
make[1]: Leaving directory `/home/ximeg/dev/sip-4.17/siplib'
make: *** [all] Error 2
似乎我需要一个Windows版的Python来编译这些东西,放在
下,但是来吧,现在事情变得太复杂了。我很确定我错过了一些简单的东西。不幸的是,我在为Windows编译方面没有太多经验,如果有任何帮助,我将不胜感激

其他快捷方式选项? 我不介意重写Python程序并使用任何其他跨平台库来捕获全局shorcuts,但除了PyGlobalShortcut之外,我没有找到任何其他库