-
Notifications
You must be signed in to change notification settings - Fork 233
Building Qt with PowerShell
[WIP]
This will guide you through using a PowerShell script to automatically download and compile Qt statically for you.
The install will default to C:\Qt\Static\{VERSION}\{PLATFORM}
(e.g. C:\Qt\Static\5.8.0\msvc2017_64
)
- MSVC-build-Qt-Static.ps1 (PowerShell script)
- MSVC 2015 or 2017 only
-
OPTIONAL
Script arguments
-QtSrcUrl (Default: "http://download.qt.io/official_releases/qt/5.8/5.8.0/single/qt-everywhere-opensource-src-5.8.0.7z")
-QtVersion (Default: "5.8.0")
-QtRoot (Default: "C:\Qt")
-QtStaticDir (Default: "$QtRoot\Static")
-QtToolsDir (Default: "$QtRoot\Tools")
-NumJobs (Default: 12)
-MSVC (Default: 2017)
-Arch (Default: "x86") (Other: "amd64")
-Release (Default: "debug-and-release") (Other: "release")
- If building for 64-bit, pass in
-Arch amd64
- To change number of jobs for CPU, pass in e.g.
-NumJobs 8
(or your # of CPU cores)
- Install PowerShell 3.0 or 4.0
- Run PowerShell as Administrator
- Enter:
Set-ExecutionPolicy RemoteSigned
... and hit Return.
-
Run the script.
-
It will download the source package.
-
It will extract the source package to
C:\Qt\src
. -
For MSVC, it will import your environment using the VS Command Prompt BAT file. Note: For VS 2017 they no longer create the necessary environment variables. If you do not have the file at
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat
you will need to adjust the path in the file. -
It will configure Qt, for example:
cmd /c "configure.bat -static -debug-and-release -platform win32-msvc -prefix $QtDir ` -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -opengl desktop -qt-sql-sqlite -no-openssl ` -opensource -confirm-license ` -make libs -nomake tools -nomake examples -nomake tests"
-
It will compile Qt with N jobs where N = # of CPU threads. This will take anywhere from 1 hour to several hours.
-
It will install Qt to
C:\Qt\Static\{VERSION}\{PLATFORM}
. -
After installing it will:
- Patch
CONFIG += static
into the platform's qmake.conf - Patch the .prl files to point to the install directory
- Create a qt.conf file in QTDIR\bin which defines the install location
- Copy the .pdb files to the install dir if using a debug-and-release or debug configuration. It doesn't do this for whatever reason.
- Patch
After it builds you can add the version manually inside Qt Creator at Tools > Build & Run > Qt Versions
See also: http://qt-project.org/wiki/How-to-build-a-static-Qt-for-Windows-MinGW