编译Qt源代码

一、

1.安装mMingW-w64

2.安装ActivePerl

3.安装python

4.下载Qt源代码

 参考:https://zhuanlan.zhihu.com/p/40271922

二、

以下脚本编译5.12.0版本成功了,在高的版本没有成功。

QtSrcDir : qt的源码路径

QtPrefixDir : 目标文件夹及路径

MingwDir : MinGW-w64的安装路径

BuildType : 构建Qt的类型

@echo off
rem ====================CONFIGURE BEFORE RUN SCRIPT!!======================
set QtSrcDir=%CD%
set QtPrefixDir=D:\ProgramFiles\Qt\qt5.12.0
set MingwDir=D:\ProgramFiles\mingw64\
set BuildType=-debug-and-release
set QtSPEC=win32-g++
set LANG = en
rem =======================================================================
 
PATH = %MingwDir%\bin;%MingwDir%\opt\bin;%SystemRoot%\system32;%SystemRoot%
 
set QT_INSTALL_PREFIX = %QtStaticDir%
set OldDir=%CD%
cd %QtSrcDir%
 
cmd /C "configure.bat -shared %BuildType% -platform %QtSPEC% -prefix %QtPrefixDir% -opensource -confirm-license -c++std c++14 -nomake examples -skip wayland -skip purchasing -skip serialbus -skip qtserialport -skip script -skip scxml -skip speech -skip location -no-opengl -qt-zlib -qt-pcre -qt-libpng -no-libjpeg -qt-freetype -no-openssl"
if ERRORLEVEL 1 goto :error
 
mingw32-make -r -k -s -j4
if ERRORLEVEL 1 goto :error
 
mingw32-make -k install
if ERRORLEVEL 1 goto :error
 
set FILE_TO_PATCH=%QtPrefixDir%\mkspecs\win32-g++\qmake.conf
echo.>>%FILE_TO_PATCH%
echo CONFIG += static>>%FILE_TO_PATCH%
 
echo ============BUILT!============
goto exitX
:error
echo ============ERROR!============
:exitX
pause
cd %OldDir%

 

posted @ 2022-03-10 16:17  ike_li  阅读(777)  评论(0编辑  收藏  举报