在windows平臺上使用mingw編譯PYQT5

1、準備工作

下載 pyqt5:https://sourceforge.net/projects/pyqt/files/PyQt5/  下載zip文件

下載 sip :點擊打開鏈接

下載 python:點擊打開鏈接

下載 mingw:點擊打開鏈接

下載 qt5:http://download.qt.io/archive/qt/  下載mingw版本

qtcreator: http://download.qt.io/official_releases/qtcreator

2、設置環境變量

解壓 pyqt5 到指定目錄,安裝qt5到指定目錄,安裝python,安裝mingw

設置python 、mingw、qt5到系統path環境變量

因爲編譯時會報hypot has not been declared的錯誤,所以要修改下python代碼
打開python 根目錄,修改include文件夾下面的python.h文件
把include“math.h”放在include“Python”之前(還是會搞了編輯源代碼的方法)。
修改Python.h
在開頭加上math.h
#ifndef Py_PYTHON_H
#define Py_PYTHON_H

#include "math.h"

3、編譯


打開CMD命令行

首先編譯sip

進入sip根目錄,執行下面命令:

python configure.py -p win32-g++
make
make install

然後編譯PyQt

進入pyqt根目錄,執行下面的命令:

python configure.py --spec win32-g++ --confirm-license

或者

python configure.py --spec win32-g++ --confirm-license --disable=QtPositioning --disable=QtNfc --disable=QtBluetooth --no-designer-plugin --no-qml-plugin

make
make install

之後就可以在Lib\site-packages\PyQt5看到你編譯好的qt5的pyd綁定


部分參考:

http://python.6.x6.nabble.com/Building-PyQt-on-Windows-problems-generating-the-C-code-td5212692.html

https://zhuanlan.zhihu.com/p/20528827

http://blog.csdn.net/sqn614/article/details/68946756


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章