Skip to content

Instantly share code, notes, and snippets.

@b-epelbaum
Last active June 23, 2025 08:47
Show Gist options
  • Save b-epelbaum/a2a8128c0435dfab57bf3c812d555fb0 to your computer and use it in GitHub Desktop.
Save b-epelbaum/a2a8128c0435dfab57bf3c812d555fb0 to your computer and use it in GitHub Desktop.
Full Qt 6.x Windows Static build procedure
Prerequisites :
1. Windows 10 host
2. Visual Studio 2019 and higher with latest Windows SDK
3. 150 GB free space
4. The following tools should be installed :
a) Cmake 3.20 and higher ( https://cmake.org/ )
b) Strawberry Perl ( https://strawberryperl.com/ )
c) Python 3 and higher ( https://www.python.org/downloads/windows/ )
d) OpenSSL binaries and libraries v1.1.x ( not 3.x ) from :https://slproweb.com/download/Win64OpenSSL-1_1_1s.exe
5. Make sure that all tools have added themselves to PATH environment variable
6. Prepare the dev-tools directory
a) Create directory named "dev-tools" on any disk ( better on disk C: - C:\dev-tools )
b) Create in directory "dev-tools" two subdirectories :
i. openssl\lib
ii. ninja
c) Download ninja tool from https://github.com/ninja-build/ninja/releases for windows and unpack the archive to folder dev-tools\ninja
d) Copy the following OpenSSL libraries from <OpenSSL Installation folder>\lib\VC\static to directory dev-tools\openssl\lib
i. libssl64MT.lib
ii. libcrypto64MT.lib
e) rename copied libraries in directory dev-tools\openssl to
libssl64MT.lib -> libssl.lib
libcrypto64MT.lib -> libcrypto.lib
f) dev-tools directory should have now the following structure
|-C:\dev-tools
|-openssl
|-lib
|-libssl.lib
|-libcrypto.lib
|-ninja
|-ninja.exe
7. Add folde dev-tools\openssl\lib abd dev-tools\ninja to a system PATH variable. It's required for building Qt projects.
Building preparation.
After setting up all prerequisites create a folder "qt-build-scripts" in any place and create there mentioned below files. For every created file copy content
of the file with the same name in this gist and save all the files.
1. build-qt6-win-static.bat
2. download.py
3. install_modules.py
4. run-build.bat
Copy a file, named "vswhere.exe" from MS Visual studio Installation to the script folder.
Usually this file resides at "C:\Program Files (x86)\Microsoft Visual Studio\Installer".
If no such file, download it from the Internet.
Now you should have the following files
c:\qt-build-scripts
|- build-qt6-win-static.bat
|- download.py
|- install_modules.py
|- run-build.bat
|- vswhere.exe
Now, edit the file "run-build.bat" accordingly to a system configuration. It's just a shortcut for running the main script - build-qt6-win-static.bat
The run-build.bat file contains only one line : calling the build-qt6-win-static.bat with parameteres, e.g.
call build-qt6-win-static.bat --qt-version=6.4 --qt-subversion=6.4.0 --devtools-path="C:\dev-tools" --source-root="D:\SDKs\Qt\6.4.0-static\src" --build-root="D:\SDKs\Qt\6.4.0-static" --vs-version=2019
Where :
--qt-version - the main Qt version ( example : 6.4 - main trunk )
--qt-subversion - the Qt build ( example - 6.4.0 - actual version )
--devtools-path - the full path to "dev-tools" directory
--source-root - the full path to the foldere where Qt sources are, or will be downloaded.
If sources are already downloaded as archive, they should be unpacked to the following subdirectory, e.g.
If --source-root is "C:\Qt\sources", then sources have to be unpacked to the folder "C:\Qt\sources\qt-everywhere-src-6.4.0"
the substring "6.4.0" should be changed to the actual Qt build version
--download Downloads and unpqcks sources from Qt repository. The sources would be downloaded in our example to the folder "C:\Qt\sources\download"
and unpacked to "C:\Qt\sources\qt-everywhere-src-6.4.0", where "6.4.0" is a version needed for a build.
--erase-archive The sources archive will be deleted after extraction for saving disk space
--build-root A root for Qt build. After successful build, it will contain intermediary folder "build" and a folder with actual static binaries
and qmake.exe, which can be selected for adding Qt Kit.
Example : if build root folder is "C:\Qt\6.4.0", thus after successful build it will look like :
|--C:\Qt\6.4.0
|--build
|--msvc2019_64 < the name of this folder is built from actual MS Visual Studio compiler version ( see the next parameter )
|--bin
qmake.exe
--vs-version A version of Visual Studio used for the build. Supported versions : 2019 and higher.
Configure script notes .
To alter the default configuration ( remove or add Qt features ), look at the following line in build-qt6-win-static.bat
call %QT_SOURCES_FOLDER%/configure.bat
this script contains a list of Qt components and can be changed, accordingly to the needs.
Look into documentation about Qt configure script at https://doc.qt.io/qt-6/windows-building.html
BEFORE BUILD :
If OpenSSL installed in default path e.g. C:\OpenSSL-Win64, rename the folder to something like C:\penSSL-Win64 before building a static Qt.
Build process :
Enter the folder where script created run a command prompt from there and type: run-build.bat
The build takes about 2-4 hours, depending of hardware configuration.
Important : do not delete folders "build" and folder with sources. A static project compilation requires those folders.
After successful build it's possible to add a new Qt kit with Visual Studio Qt plug-in, or Qt Creator Kit manager.
The projects, which are using the static build must be compiled with static runtime linking, e.g. with VS compiler options /MT and /MTd ( for release and debug respectively ).
Visual studio specific issues .
Sometimes, a full build does not compile and links needed static plugins.
Pay attention, that build process ( output window ) compile files, called qtvars_plugin_import.cpp.
Without compiling those files the program won't run, showing error either about platform plugin, or lack of TLS support ( if using SSL connections )
If files do not compile, just re-run Build solution command.
rem ---- Change versions and paths acccordingly to the actual Qt and machine configurations
call build-qt6-win-static.bat --qt-version=6.4 --qt-subversion=6.4.1 --devtools-path="C:\dev-tools" --source-root="C:\Qt\6.4.1-static\src" --build-root="C:\SDKs\Qt\6.4.1-static" --vs-version=2019 --download --erase-archive
@echo off
setlocal
setlocal enabledelayedexpansion
cls
set BEGINTIME=%TIME%
echo **********************************************************************
echo *********** QT Static Windows Build Script **********************
echo **********************************************************************
rem buildqt_6_4_static.bat --download --qt-version=6.4 --qt-subversion=6.4.0 --devtools-path="C:\dev-tools" --erase-archive --source-root="D:\SDKs\Qt\6.4.0-static\src" --build-root="D:\SDKs\Qt\6.4.0-static" --vs-version=2019
set ORIG_FOLDER=%~dp0
SET CMD=%~1
IF "%CMD%" == "" (
call :SHOWUSAGE
EXIT /B 1
)
echo **********************************************************************
echo tarting build %DATE% %TIME%
echo **********************************************************************
SET PARAM_DOWNLOAD=0
SET PARAM_ERASE_ARCHIVE=0
SET PARAM_ERASE_PCH=0
SET PARAM_QT_VERSION=
SET PARAM_QT_SUBVERSION=
SET PARAM_DEV_TOOLS=
SET PARAM_SOURCE_ROOT=
SET PARAM_BUILD_ROOT=
SET PARAM_VSVERSION=2019
SET DELIM =--
:args
SET PARAM=%~1
SET ARG=%~2
call :startsWith %PARAM% %DELIM%
rem ECHO %errorlevel%
rem if %errorlevel% neq 1 (
rem ECHO %PARAM%=
rem shift
rem goto :args
rem )
rem ECHO %PARAM%=%ARG%
IF "%PARAM%" == "--qt-version" (
IF NOT "%ARG%" == "" (
SET PARAM_QT_VERSION=%ARG%
SHIFT
SHIFT
) ELSE (
ECHO Error : Missing --qt-version parameter value. 1>&2
call :SHOWUSAGE
EXIT /B 1
)
) ELSE IF "%PARAM%" == "--qt-subversion" (
IF NOT "%ARG%" == "" (
SET PARAM_QT_SUBVERSION=%ARG%
SHIFT
SHIFT
) ELSE (
ECHO Error : Missing --qt-subversion parameter value. 1>&2
call :SHOWUSAGE
EXIT /B 1
)
) ELSE IF "%PARAM%" == "--devtools-path" (
IF NOT "%ARG%" == "" (
SET PARAM_DEV_TOOLS=%ARG%
SHIFT
SHIFT
) ELSE (
ECHO Error : Missing --devtools-path parameter value. 1>&2
call :SHOWUSAGE
EXIT /B 1
)
) ELSE IF "%PARAM%" == "--source-root" (
IF NOT "%ARG%" == "" (
SET PARAM_SOURCE_ROOT=%ARG%
SHIFT
SHIFT
) ELSE (
ECHO Error : Missing --source-root parameter value. 1>&2
call :SHOWUSAGE
EXIT /B 1
)
) ELSE IF "%PARAM%" == "--build-root" (
IF NOT "%ARG%" == "" (
SET PARAM_BUILD_ROOT=%ARG%
SHIFT
SHIFT
) ELSE (
ECHO Error : Missing --build-root parameter value. 1>&2
call :SHOWUSAGE
EXIT /B 1
)
) ELSE IF "%PARAM%" == "--vs-version" (
IF NOT "%ARG%" == "" (
SET PARAM_VSVERSION=%ARG%
SHIFT
SHIFT
) ELSE (
ECHO Error : Missing --vs-version parameter value. 1>&2
call :SHOWUSAGE
EXIT /B 1
)
) ELSE IF "%PARAM%" == "--download" (
SET PARAM_DOWNLOAD=1
SHIFT
) ELSE IF "%PARAM%" == "--erase-archive" (
SET PARAM_ERASE_ARCHIVE=1
SHIFT
) ELSE IF "%PARAM%" == "--erase-pch" (
SET PARAM_ERASE_PCH=1
SHIFT
) ELSE IF "%PARAM%" == "" (
GOTO endargs
) ELSE (
ECHO Unrecognized option %1. 1>&2
call :SHOWUSAGE
EXIT /B 1
)
GOTO args
:endargs
rem check input parameters
if [%PARAM_QT_VERSION%]==[] (
ECHO Error : Missing --qt-version parameter. Build aborted.
call :SHOWUSAGE
EXIT /B 1
)
if [%PARAM_QT_SUBVERSION%]==[] (
ECHO Error : Missing --qt-subversion parameter. Build aborted.
call :SHOWUSAGE
EXIT /B 1
)
if [%PARAM_DEV_TOOLS%]==[] (
ECHO Error : Missing --devtools-path parameter. Build aborted.
call :SHOWUSAGE
EXIT /B 1
)
if [%PARAM_SOURCE_ROOT%]==[] (
ECHO Error : Missing --source-root parameter. Build aborted.
call :SHOWUSAGE
EXIT /B 1
)
if [%PARAM_BUILD_ROOT%]==[] (
ECHO Error : Missing --build-root parameter. Build aborted.
call :SHOWUSAGE
EXIT /B 1
)
if %PARAM_VSVERSION% LSS 2019 ( echo Error : Visual Studio version should be at least 2019. Build Aborted.
EXIT /B 1
)
set VS_VERSION=16.0
set VS_VERSION_SEARCH_MIN=16
set VS_VERSION_SEARCH_MAX=17
set VS_VERSION_STRING=MS Visual Studio %PARAM_VSVERSION%
if %PARAM_VSVERSION% == 2022 (
set VS_VERSION=17.0
set VS_VERSION_SEARCH_MIN=17
set VS_VERSION_SEARCH_MAX=18
set VS_VERSION_STRING%=MS Visual Studio 2022
)
echo Locating MSBUILD [ version %VS_VERSION% ] folder...
for /f "usebackq tokens=*" %%i in (`vswhere -version [%VS_VERSION_SEARCH_MIN%^,%VS_VERSION_SEARCH_MAX%^) -products * -requires Microsoft.Component.MSBuild -property installationPath`) do (
set MSBUILD_DIR=%%i
)
if "%MSBUILD_DIR%"=="" ( echo Error : Cannot locate MSBUILD [ version %VS_VERSION% ]. Build Aborted.
EXIT /B 1
)
echo MSBUILD [ version %VS_VERSION% ] located at %MSBUILD_DIR%
set VC_BAT_PATH=%MSBUILD_DIR%\VC\Auxiliary\Build\vcvarsall.bat
if not exist "%VC_BAT_PATH%" (
echo Error : Cannot locate vcvarsall.bat file [ version %VS_VERSION% ]. Build Aborted.
EXIT /B 1)
echo vcvarsall.bat [ version %VS_VERSION% ] located at %VC_BAT_PATH%
echo.
echo Setting build environment...
CALL "%VC_BAT_PATH%" amd64 || EXIT /B
echo.
echo Checking and cleaning build folders
rem prepare folders
SET "QT_VERSION=%PARAM_QT_VERSION%"
SET "QT_SUBVERSION=%PARAM_QT_SUBVERSION%"
SET "QT_SOURCES_ROOT_FOLDER=%PARAM_SOURCE_ROOT%"
SET "QT_SOURCES_DOWNLOAD_FOLDER=%PARAM_SOURCE_ROOT%\download"
SET "QT_SOURCES_FOLDER=%QT_SOURCES_ROOT_FOLDER%\qt-everywhere-src-%QT_SUBVERSION%"
SET "QT_BUILD_FOLDER=%PARAM_BUILD_ROOT%\build"
SET "QT_INSTALL_FOLDER=%PARAM_BUILD_ROOT%\msvc%PARAM_VSVERSION%_64"
SET "QT_DEV_TOOLS=%PARAM_DEV_TOOLS%"
rem %QT_INSTALL_ROOT% - Build and install folders based on
rem %QT_SOURCE_ROOT% - download and unpack sources folder
rem %QT_BUILD_FOLDER% - build folder
rem build download string
SET QT_DOWNLOAD_URL=https://download.qt.io/archive/qt/%QT_VERSION%/%QT_SUBVERSION%/single/qt-everywhere-src-%QT_SUBVERSION%.zip
SET QT_DOWNLOAD_FILE=%QT_SOURCES_ROOT_FOLDER%\qt-everywhere-src-%QT_SUBVERSION%.zip
echo:
echo:
echo Process Parameters :
echo Current folder : %ORIG_FOLDER%
echo QT Version : %QT_VERSION%
echo QT Subversion : %QT_SUBVERSION%
echo QT Sources Download Folder : %QT_SOURCES_DOWNLOAD_FOLDER%
echo QT Sources Folder : %QT_SOURCES_FOLDER%
echo QT Build Folder : %QT_BUILD_FOLDER%
echo Qt Install folder : %QT_INSTALL_FOLDER%
echo Dev Tools folder : %QT_DEV_TOOLS%
if %PARAM_DOWNLOAD%==1 (echo Download sources ? YES ) else (echo Download sources ? NO )
if %PARAM_DOWNLOAD%==1 (echo Qt sources download URL : %QT_DOWNLOAD_URL% )
if %PARAM_DOWNLOAD%==1 (echo Qt sources download file : %QT_DOWNLOAD_FILE% )
if %PARAM_ERASE_ARCHIVE%==1 (echo Delete sources after unpack ? YES ) else (echo Delete sources adter unpack ? NO )
if %PARAM_ERASE_PCH%==1 (echo Delete *.pch files after build ? YES ) else (echo Delete *.pch files after build ? NO )
echo VS Version : %VS_VERSION_STRING% [ compiler version : %VS_VERSION% ] 
echo:
rem checking the dev tools prerequisites
if not exist "%QT_DEV_TOOLS%%\ninja\ninja.exe" (
echo Warning : ninja.exe has not been found at %QT_DEV_TOOLS%%\ninja folder. Check if ninja executable path listed in PATH
)
if not exist "%QT_DEV_TOOLS%\openssl\lib\libcrypto.lib" (
echo Error : Cannot locate openssl libcrypto.lib library at at %QT_DEV_TOOLS%%\openssl\lib folder. Build Aborted.&exit /B 1
)
if not exist "%QT_DEV_TOOLS%\openssl\lib\libssl.lib" (
echo Error : Cannot locate openssl libssl.lib library at at %QT_DEV_TOOLS%%\openssl\lib folder. Build Aborted.&exit /B 1
)
rem for sources we need 5368709120 bytes
rem for build we need 139586437120 bytes
rem total we need 144955146240 bytes
rem checking available space
echo Checking available disk space...
SET SAME_DISK=1
if %QT_SOURCES_FOLDER:~0,2% NEQ %QT_BUILD_FOLDER:~0,2% SET SAME_DISK=0
if %SAME_DISK%==1 (
wmic LogicalDisk where "DeviceID='%QT_SOURCES_FOLDER:~0,2%' and FreeSpace > 144955146240" get DeviceID 2>&1 ^
| find /i "%QT_SOURCES_FOLDER:~0,2%" >nul || (echo Error : Not enough free space for sources. Required at least 140 GB free on disk %QT_SOURCES_FOLDER:~0,2%. Build Aborted.&exit /B 1)
) else (
wmic LogicalDisk where "DeviceID='%QT_SOURCES_FOLDER:~0,2%' and FreeSpace > 5368709120" get DeviceID 2>&1 ^
| find /i "%QT_SOURCES_FOLDER:~0,2%" >nul || (echo Error : Not enough free space for sources. Required at least 5 GB free on disk %QT_SOURCES_FOLDER:~0,2%. Build Aborted.&exit /B 1)
wmic LogicalDisk where "DeviceID='%QT_BUILD_FOLDER:~0,2%' and FreeSpace > 5368709120" get DeviceID 2>&1 ^
| find /i "%QT_BUILD_FOLDER:~0,2%" >nul || (echo Error : Not enough free space for sources. Required at least 130 GB free on disk %QT_BUILD_FOLDER:~0,2%. Build Aborted.&exit /B 1)
)
echo Enough disk space detected.
rem ---------------------------------------------------------------------------
rem Preparing build folder
rem ---------------------------------------------------------------------------
if not exist "%QT_BUILD_FOLDER%\" (
echo Build Path %QT_BUILD_FOLDER% does not exist. Creating...
md %QT_BUILD_FOLDER% || exit /B 1
) else (
echo Build Path %QT_BUILD_FOLDER% exists. Cleaning up build folder...
cd %QT_BUILD_FOLDER%
for /F "delims=" %%i in ('dir /b') do (rmdir "%%i" /s/q || del "%%i" /s/q ) || exit /B 1
echo Build Path %QT_BUILD_FOLDER% has been cleaned up.
echo:
)
cd %ORIG_FOLDER%
rem ---------------------------------------------------------------------------
rem Preparing source folder
rem ---------------------------------------------------------------------------
if %PARAM_DOWNLOAD%==0 goto :ignore_download
if %PARAM_DOWNLOAD% == 1 (
rem check if source folder root exists
if not exist "%QT_SOURCES_ROOT_FOLDER%\" (
mkdir "%QT_SOURCES_ROOT_FOLDER%"
) else (
if not exist "%QT_SOURCES_DOWNLOAD_FOLDER%\" (
echo The download path %QT_SOURCES_ROOT_FOLDER% is ready
) else (
echo For downloading sources the download path %QT_SOURCES_DOWNLOAD_FOLDER% have to be cleaned. Cleaning download path...
cd %QT_SOURCES_ROOT_FOLDER%
for /F "delims=" %%i in ('dir /b') do (
echo Deleting '%%i'...
rmdir "%%i" /s/q || del "%%i" /s/q ) || exit /B 1
echo The download path %QT_SOURCES_ROOT_FOLDER% is ready.
)
)
)
)
cd %ORIG_FOLDER%
echo Updating python modules needed for download and unpacking...
call python.exe -m pip install --upgrade pip
call python install_modules.py
echo  
echo Python modules has been updated. Start downloading ...
echo:
set STARTTIME=%TIME%
set ERRORLEVEL=
echo Calling download and extract script "python download.py %PARAM_QT_VERSION% %PARAM_QT_SUBVERSION% %QT_SOURCES_ROOT_FOLDER%"
call python download.py %PARAM_QT_VERSION% %PARAM_QT_SUBVERSION% %QT_SOURCES_ROOT_FOLDER%
if !ERRORLEVEL! NEQ 0 (
echo Error : Cannot Download source archive or unzip it. Build Aborted.
EXIT /B 1 )
)
set ENDTIME=%TIME%
call :elapsed_time %STARTTIME% %ENDTIME% DURATION
echo The Qt sources have been downloaded and extracted sucessfully. [Duration = %DURATION%]. Starting configuration script...
if [%PARAM_ERASE_ARCHIVE%]==[] goto :start_configure
if %PARAM_ERASE_ARCHIVE% == 1 (
if exist %QT_SOURCES_DOWNLOAD_FOLDER% rmdir %QT_SOURCES_DOWNLOAD_FOLDER% /s/q
)
goto :start_configure
:ignore_download
echo:
rem check if sources exist
echo No source download requested, assuming the sources are already at %QT_SOURCES_FOLDER%
if not exist "%QT_SOURCES_FOLDER%\" (
echo Error : Source folder does not exist. Build Aborted.
exit /B 1
)
For /F %%A in ('dir /b /a %QT_SOURCES_FOLDER%') Do (
goto :src_not_empty
)
echo Error : Source folder is empty. Build Aborted.
exit /B 1
:src_not_empty
echo The source folder %QT_SOURCES_ROOT_FOLDER% is OK.
:start_configure
echo Starting build configure script...
rem configure path
SET _ROOT=%QT_SOURCES_FOLDER%
SET PATH=%_ROOT%\qtbase\bin;%PATH%
SET PATH=%QT_DEV_TOOLS%\openssl;%PATH%
SET PATH=%QT_DEV_TOOLS%\ninja;%PATH%
SET PATH=%QT_DEV_TOOLS%\openssl\include;%PATH%
SET PATH=%QT_DEV_TOOLS%\openssl\lib;%PATH%
rem SET PATH=%QT_DEV_TOOLS%\perl;%PATH%
rem SET PATH=%QT_DEV_TOOLS%\perl\bin;%PATH%
SET PATH=%LLVM_INSTALL_DIR%;%PATH%
SET PATH=%LLVM_INSTALL_DIR%\bin;%PATH%
SET _ROOT=
set QT_SOURCES_FOLDER_SLASH=%QT_SOURCES_FOLDER:\=/%
set QT_INSTALL_FOLDER_SLASH=%QT_INSTALL_FOLDER:\=/%
set QT_DEV_TOOLS_SLASH=%QT_DEV_TOOLS:\=/%
echo Configure Dev Tools folder %QT_DEV_TOOLS_SLASH%
echo Configure Sources folder %QT_SOURCES_FOLDER_SLASH%
echo Configure Install folder %QT_INSTALL_FOLDER_SLASH%
echo Configure Build folder %QT_BUILD_FOLDER%
set OPENSSL_USE_STATIC_LIBS=ON
set "OPENSSL_ROOT_DIR=%QT_DEV_TOOLS_SLASH%/openssl"
set OPENSSL_MSVC_STATIC_RT=ON
set CMAKE_USE_OPENSSL=ON
set "CMAKE_PREFIX_PATH=%QT_DEV_TOOLS_SLASH%"
set CL=/MP
set LLVM_INSTALL_DIR="c:/LLVM"
echo Calling a configuration script at "%QT_SOURCES_FOLDER%\configure.bat"
cd %QT_BUILD_FOLDER%
set STARTTIME=%TIME%
echo **********************************************************************
echo Configure start time %DATE% %TIME%
echo **********************************************************************
call %QT_SOURCES_FOLDER%/configure.bat ^
-prefix %QT_INSTALL_FOLDER% ^
-platform win32-msvc ^
-debug-and-release ^
-optimize-size ^
-force-debug-info ^
-static-runtime ^
-static ^
-DQT_NO_EXCEPTIONS=0 ^
-c++std c++17 ^
-opensource ^
-opengl desktop ^
-confirm-license ^
-qt-zlib ^
-qt-libjpeg ^
-qt-libpng ^
-qt-freetype ^
-qt-tiff ^
-qt-webp ^
-qt-pcre ^
-sql-sqlite ^
-sql-odbc ^
-qt-sqlite ^
-no-sql-psql ^
-ssl ^
-openssl ^
-openssl-linked ^
-DFEATURE_clangcpp=ON ^
-DOPENSSL_USE_STATIC_LIBS=ON ^
-DOPENSSL_ROOT_DIR="%QT_DEV_TOOLS_SLASH%/openssl" ^
-DOPENSSL_MSVC_STATIC_RT=ON ^
-DCMAKE_USE_OPENSSL=ON ^
-DBUILD_TESTING=OFF ^
-DCMAKE_PREFIX_PATH="%QT_DEV_TOOLS_SLASH%/openssl/lib" ^
-DCMAKE_INCLUDE_PATH="%QT_DEV_TOOLS_SLASH%/openssl/include" ^
-DCMAKE_LIBRARY_PATH="%QT_DEV_TOOLS_SLASH%/openssl/lib" ^
-nomake tests ^
-nomake examples ^
-no-feature-accessibility ^
-no-feature-appstore-compliant ^
-no-feature-gssapi ^
-no-feature-itemmodeltester ^
-no-feature-testlib_selfcover ^
-no-feature-tuiotouch ^
-no-feature-valgrind ^
-no-feature-lcdnumber ^
-no-harfbuzz ^
-skip qt3d ^
-skip qtactiveqt ^
-skip qtcanvas3d ^
-skip qtconnectivity ^
-skip qtdoc ^
-skip qtcoap ^
-skip qtdatavis3d ^
-skip qtgamepad ^
-skip qtlottie ^
-skip qtlocation ^
-skip qtmqtt ^
-skip qtopcua ^
-skip qtserialbus ^
-skip qtserialport ^
-skip qtpositioning ^
-skip qtpurchasing ^
-skip qtquickcontrols ^
-skip qtquickcontrols2 ^
-skip qtquicktimeline ^
-skip qtquick3d ^
-skip qtremoteobjects ^
-skip qtvirtualkeyboard ^
-skip qtscxml ^
-skip qtsensors ^
-skip qtwayland ^
-skip qtpositioning ^
-skip qtwebchannel ^
-skip qtwebengine ^
-skip qtconnectivity ^
-skip qtwebview
set ENDTIME=%TIME%
call :elapsed_time %STARTTIME% %ENDTIME% DURATION
echo **** Configuration done in [ %DURATION% ] *******************
set STARTTIME=%TIME%
echo:
echo Starting build...
cd %QT_BUILD_FOLDER%
cmake --build . --parallel
echo ****** Build complete *****
echo :
echo Installing build...
ninja install
set ENDTIME=%TIME%
call :elapsed_time %STARTTIME% %ENDTIME% DURATION
echo Build and installation complete in [%DURATION%] *******************
if [%PARAM_ERASE_ARCHIVE%]==[] goto :end
cd %QT_BUILD_FOLDER%
del /S *.pch
echo Build Path All PCH files in folder %QT_BUILD_FOLDER% have been deleted.
:end
call :elapsed_time %BEGINTIME% %ENDTIME% DURATION
echo Total Build time : %DURATION%
echo **********************************************************************
echo *********** QT Static Windows Build COMPLETE **********************
echo **********************************************************************
rem findstr /m "computerhope" hope.txt
rem if %errorlevel%==0 (
rem echo There is hope!
rem check if opnssl libraries are configured correctly
rem d:\SDKs\Qt\6.4.0-static\build\CMakeFiles\impl-Debug.ninja
rem \dev-tools\openssl\lib\libcrypto.lib
cd %ORIG_FOLDER%
:NORMALIZEPATH
SET RETVAL=%~dpfn1
EXIT /B
:SHOWUSAGE
echo:
echo ------------------------------------------------------------------------------------------------------------------------
echo Usage : %~n0%~x0
echo --qt-version=[Qt Major Version; ex : 6.4] : required
echo --qt-subversion=[Qt Subversion; ex : 6.4.0] : required
echo --devtools-path=[Path to development tools] : required
echo --download : optional [download sources from Qt repository]
echo --erase-archive : optional [erase source archive after unpacking]
echo --erase-pch : optional [erase all PCH files after build]
echo --source-root[Path to sources root] : required
echo --build-root=[Path to build root] : required
echo --vs-version=[MS VIsual Studio Version] : optional; default 2019
echo:
echo Example : %~n0%~x0 --qt-version=6.4 --qt-subversion=6.4.0 --devtools-path="C:\dev-tools" --download --erase-archive --source-root="C:\Qt\src" --build-root="c:\Qt\6.4.0-static" --vs-version=2019
EXIT /B 1
:time_to_centiseconds
:: %~1 - time
:: %~2 - centiseconds output variable
setlocal
set _time=%~1
for /F "tokens=1-4 delims=:.," %%a in ("%_time%") do (
set /A "_result=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
)
endlocal & set %~2=%_result%
goto :eof
:centiseconds_to_time
:: %~1 - centiseconds
:: %~2 - time output variable
setlocal
set _centiseconds=%~1
rem now break the centiseconds down to hors, minutes, seconds and the remaining centiseconds
set /A _h=%_centiseconds% / 360000
set /A _m=(%_centiseconds% - %_h%*360000) / 6000
set /A _s=(%_centiseconds% - %_h%*360000 - %_m%*6000) / 100
set /A _hs=(%_centiseconds% - %_h%*360000 - %_m%*6000 - %_s%*100)
rem some formatting
if %_h% LSS 10 set _h=0%_h%
if %_m% LSS 10 set _m=0%_m%
if %_s% LSS 10 set _s=0%_s%
if %_hs% LSS 10 set _hs=0%_hs%
set _result=%_h%:%_m%:%_s%.%_hs%
endlocal & set %~2=%_result%
goto :eof
:elapsed_time
:: %~1 - time1 - start time
:: %~2 - time2 - end time
:: %~3 - elapsed time output
setlocal
set _time1=%~1
set _time2=%~2
call :time_to_centiseconds %_time1% _centi1
call :time_to_centiseconds %_time2% _centi2
set /A _duration=%_centi2%-%_centi1%
call :centiseconds_to_time %_duration% _result
endlocal & set %~3=%_result%
goto :eof
:startsWith [%1 - string to be checked;%2 - string for checking ]
@echo off
rem :: sets errorlevel to 1 if %1 starts with %2 else sets errorlevel to 0
setlocal EnableDelayedExpansion
set "string=%~1"
set "checker=%~2"
rem set "var=!string:%~2=&echo.!"
set LF=^
rem ** Two empty lines are required
rem echo off
for %%L in ("!LF!") DO (
for /f "delims=" %%R in ("!checker!") do (
rem set "var=!string:%%~R%%~R=%%~L!"
set "var=!string:%%~R=#%%L!"
)
)
for /f "delims=" %%P in (""!var!"") DO (
if "%%~P" EQU "#" (
endlocal & exit /b 1
) else (
endlocal & exit /b 0
)
)
import requests
import shutil
import sys
from tqdm.auto import tqdm
from os import path
from sys import argv
import os, shutil
import errno
from zipfile import ZipFile, is_zipfile
# make an HTTP request within a context manager
def dl(_qtversion, _qtsubversion, _rootpath ):
fullUrl = "https://download.qt.io/archive/qt/" + _qtversion + "/" + _qtsubversion + "/single/qt-everywhere-src-" + _qtsubversion + ".zip"
print("Downloading source archive from " + fullUrl )
dlPath = _rootpath +"/download"
print("Download folder : " + dlPath )
fullFilePath = dlPath + "/qt-everywhere-src-" + _qtsubversion + ".zip"
print("Downloaded file path : " + fullFilePath )
try:
os.makedirs(dlPath)
except OSError as e:
if errno.EEXIST != e.errno:
raise
for filename in os.listdir(dlPath):
file_path = os.path.join(dlPath, filename)
try:
if os.path.isfile(file_path) or os.path.islink(file_path):
os.unlink(file_path)
elif os.path.isdir(file_path):
shutil.rmtree(file_path)
except Exception as e:
print('Failed to delete %s. Reason: %s' % (file_path, e))
sys.exit(1)
with requests.get(fullUrl, stream=True) as r:
# check header to get content length, in bytes
total_length = int(r.headers.get("Content-Length"))
# implement progress bar via tqdm
with tqdm.wrapattr(r.raw, "read", total=total_length, desc="")as raw:
# save the output to a file
with open(fullFilePath, 'wb')as output:
shutil.copyfileobj(raw, output)
if path.exists(fullFilePath):
if is_zipfile(fullFilePath):
print(fullFilePath + " is a valid ZIP file")
else:
print(fullFilePath + " is a NOT valid ZIP file")
sys.exit(2)
print("Extracting: " + fullFilePath)
with ZipFile(fullFilePath,"r") as zip_ref:
for file in tqdm(iterable=zip_ref.namelist(), total=len(zip_ref.namelist())):
zip_ref.extract(member=file, path=_rootpath)
sys.exit(0)
else:
print("Cannot find:" + fullFilePath)
sys.exit(3)
script, _qtversion, _qtsubversion, _rootpath = argv
dl(_qtversion, _qtsubversion, _rootpath )
import sys
import subprocess
# implement pip as a subprocess:
subprocess.check_call([sys.executable, '-m', 'ensurepip', '--upgrade'])
subprocess.check_call([sys.executable, '-m', 'pip', 'install',
'update'])
subprocess.check_call([sys.executable, '-m', 'pip', 'install',
'requests'])
subprocess.check_call([sys.executable, '-m', 'pip', 'install',
'tqdm'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment