Building qt from source windows

Qt Documentation

Contents

This page describes the process of configuring and building Qt for Windows. Before building, there are some requirements that are given in more detail in the Qt for Windows — Requirements document.

You can download the Qt 5 sources from the Downloads page. For more information, visit the Getting Started with Qt page.

Step 1: Install the License File (Commercially Licensed Qt Only)

If you use Qt with a commercial license, the Qt tools look for a local license file. If you are using a binary installer or the commercial Qt Creator, your licenses are automatically fetched and stored in your local user profile ( %USERPROFILE%\AppData\Roaming\Qt\qtlicenses.ini file).

If you do not use any binary installer or Qt Creator, you can download the respective license file from your Qt Account Web portal and save it to your user profile as %USERPROFILE%\.qt-license . If you prefer a different location or file name, you need to set the QT_LICENSE_FILE environment variable to the respective file path.

Step 2: Unpack the Archive

Uncompress the files into the directory you want Qt installed; e.g. C:\Qt\%VERSION% .

Note: The install path must not contain any spaces or Windows specific file system characters.

Step 3: Set the Environment Variables

We recommend creating a desktop link that opens a command prompt with the environment set up similar to the Command Prompt menu entries provided by Visual Studio. This is done by creating an application link passing a .cmd file setting up the environment and the command line option /k (remain open) to cmd.exe .

Assuming the file is called qt5vars.cmd and the Qt folder is called Qt-5 and located under C:\Qt :

A desktop link can then be created by specifying the command %SystemRoot%\system32\cmd.exe /E:ON /V:ON /k C:\Qt\qt5vars.cmd as application and C:\Qt\Qt-5 as working directory.

Note: Setups for MinGW are similar; they differ only in that the bin folder of the installation should be added to the path instead of calling the Visual Studio setup script. For MinGW, please make sure that no sh.exe can be found in the path, as it affects mingw32-make .

Settings required by the additional libraries (see Qt for Windows — Requirements) should also go this file below the call to the Windows SDK setup script.

Step 4: Build the Qt Library

The default behavior of configure is to create an in-source build of Qt 5. If you want to install Qt 5 to a separate location, you need to specify the command line option -prefix . Alternatively, the command line option -developer-build creates an in-source build for developer usage.

To configure the Qt library for a debug build for your machine, type the following command in the command prompt:

The Configure Options page contains more information about the configure options.

To build Qt using jom, type:

If you do not have jom installed, type:

If an installation prefix was given, type jom install , nmake install or mingw32-make install .

Note: If you later need to reconfigure and rebuild Qt from the same location, ensure that all traces of the previous configuration are removed by entering the build directory and typing nmake distclean before running configure again.

Parallel Builds

jom is a replacement for nmake which makes use of all CPU cores and thus speeds up building.

Step 5: Build the Qt Documentation

For the Qt reference documentation to be available in Qt Assistant, you must build it separately:

This will build the documentation in the build folder. If you have installed Qt in a separate location, you will also need to install the documentation:

Читайте также:  Как вернуть среду восстановления windows 10

В© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.

Qt Documentation

Contents

This page describes the process of configuring and building Qt for Windows. To download and install a pre-built Qt for Windows, follow the instructions on the Getting Started with Qt page.

Step 1: Getting the Sources

Qt sources can be installed in the Qt Online Installer. Source packages are also available as Git repositories, as archives in the Qt Account (commercial users), and on download.qt.io (open-source users).

If you install the sources through the Qt Online Installer, they will be available in the Qt installation directory, for instance C:\Qt\6.0.3\Src .

If you downloaded the source archive, extract it to a directory of your choice, for instance C:\dev\Qt\src .

Note: The path to the source directory must not contain any spaces or Windows specific file system characters. The path should also be kept short. This avoids issues with too long file paths in the compilation phase.

Step 2: Install Build Requirements

To build Qt from sources you need a build environment with a supported compiler and various build tools available:

Build Tools

  • CMake (available in the Qt online installer)
  • Ninja (available in the Qt online installer)
  • ActivePerl — Install a recent version of ActivePerl (download page).
  • Python — Install Python from the here.

The executables cmake.exe , ninja.exe , perl.exe , and python.exe must be available in your build environment. You achieve this by adding the respective directory to your PATH environment variable.

Note: Please make sure that the perl executable from ActivePerl is found in the path before a potential perl executable provided by msysgit, since the latter is outdated.

Compilers

The following compilers and configurations are supported in Qt 6.0:

Operating System Architecture Compiler
Windows 10 x86_64 MSVC 2019, MinGW 8.1

QDoc Dependencies

QDoc uses Clang to parse C++ code. If you wish to build QDoc manually, refer to Installing Clang for QDoc for specific build requirements.

Step 3: Set the Environment Variables

We recommend creating a desktop link that opens a command prompt with the environment set up similar to the Command Prompt menu entries provided by Visual Studio. This is done by creating an application link passing a .cmd file setting up the environment and the command line option /k (remain open) to cmd.exe .

Assuming the file is called qt6vars.cmd and the Qt folder is called C:\Qt\6.0.3\Src :

A desktop link can then be created by specifying the command %SystemRoot%\system32\cmd.exe /E:ON /V:ON /k C:\Qt\qt6vars.cmd as application.

Depending on your individual setup, you might also need to make the installation directories of CMake, ninja, Perl, and Python part of the SET %PATH% line above.

Note: Setups for MinGW are similar; they differ only in that the bin folder of the installation should be added to the path instead of calling the Visual Studio setup script. For MinGW, please make sure that no sh.exe can be found in the path, as it affects mingw32-make .

Step 4: Build the Qt Library

To configure the Qt library for your machine type, run the configure.bat script in the source directory.

By default, Qt is configured for installation in the C:\Program Files\Qt directory, but this can be changed by using the -prefix option.

The Configure Options page contains more information about the configure options. See Qt for Windows — Graphics Acceleration for specific options regarding graphics acceleration.

В© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.

Qt Documentation

Contents

This page describes the process of configuring and building Qt for Windows. Before building, there are some requirements that are given in more detail in the Qt for Windows — Requirements document.

You can download the Qt 5 sources from the Downloads page. For more information, visit the Getting Started with Qt page.

Step 1: Install the License File (Commercial Editions Only)

If you have the commercial edition of Qt, copy the license file from your account on the distribution server into your home directory (this may be known as the userprofile environment variable) and rename it to .qt-license . This renaming process must be done using a command prompt on Windows, not with Windows Explorer. For example on Windows 2000, %USERPROFILE% should be something like C:\Documents and Settings\username

For the open source version you do not need a license file.

Step 2: Unpack the Archive

Uncompress the files into the directory you want Qt installed; e.g. C:\Qt\%VERSION% .

Note: The install path must not contain any spaces or Windows specific file system characters.

Step 3: Set the Environment Variables

We recommend creating a desktop link that opens a command prompt with the environment set up similar to the Command Prompt menu entries provided by the Windows SDKs. This is done by creating an application link passing a .cmd file setting up the environment and the command line option /k (remain open) to cmd.exe .

Assuming the file is called qt5vars.cmd and the Qt folder is called qt-5 and located under C:\qt :

A desktop link can then be created by specifying the command %SystemRoot%\system32\cmd.exe /E:ON /V:ON /k c:\qt\qt5vars.cmd as application and c:\qt\qt-5 as working directory.

Note: Setups for MinGW are similar; they differ only in that the bin folder of the installation should be added to the path instead of calling the Windows SDK setup script. For MinGW, please make sure that no sh.exe can be found in the path, as it affects mingw32-make .

Settings required by the additional libraries (see Qt for Windows Requirements) should also go this file below the call to the Windows SDK setup script.

Step 4: Build the Qt Library

The default behavior of configure is to create an in-source build of Qt 5. If you want to install Qt 5 to a separate location, you need to specify the command line option -prefix . Alternatively, the command line option -developer-build creates an in-source build for developer usage.

To configure the Qt library for a debug build for your machine, type the following command in the command prompt:

The Configure Options page contains more information about the configure options.

To build Qt using jom, type:

If you do not have jom installed, type:

If an installation prefix was given, type jom install , nmake install or mingw32-make install .

Note: If you later need to reconfigure and rebuild Qt from the same location, ensure that all traces of the previous configuration are removed by entering the build directory and typing nmake distclean before running configure again.

Parallel Builds

jom is a replacement for nmake which makes use of all CPU cores and thus speeds up building.

В© 2017 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.

Qt Documentation

Contents

There are two ways to install Qt:

  1. through the Qt Installers — downloads and installs Qt
  2. through the Qt sources.

You can download the Qt 5 installers and sources from the Downloads page. For more information, visit the Getting Started with Qt page.

This page lists the relevant information for installing Qt by building the Qt sources. The installation procedure is different on each Qt platform. This page collects the relevant information for the supported platforms.

General Installation Information

Building Qt revolves around using configure to configure Qt for a particular platform with a particular set of Qt features or modules. For more information, visit the following page:

Windows

macOS

Linux/X11

Embedded Linux

Android

Universal Windows Platform (UWP)

Additional Information

The top-level qt5 Git repository contains a set of build instructions in the form of provisioning scripts, used by Qt’s continuous integration (CI) system to build and test the supported Reference Configurations. These scripts are useful for anyone building Qt from source, as they provide information on the tools and components that are required for each configuration.

В© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.

Qt Documentation

Contents

This page describes the process of configuring and building Qt for Windows. Before building, there are some requirements that are given in more detail in the Qt for Windows — Requirements document.

You can download the Qt 5 sources from the Downloads page. For more information, visit the Getting Started with Qt page.

Step 1: Install the License File (Commercially Licensed Qt Only)

If you use Qt with a commercial license, the Qt tools look for a local license file. If you are using a binary installer or the commercial Qt Creator, your licenses are automatically fetched and stored in your local user profile ( %USERPROFILE%\AppData\Roaming\Qt\qtlicenses.ini file).

If you do not use any binary installer or Qt Creator, you can download the respective license file from your Qt Account Web portal and save it to your user profile as %USERPROFILE%\.qt-license . If you prefer a different location or file name, you need to set the QT_LICENSE_FILE environment variable to the respective file path.

Step 2: Unpack the Archive

Uncompress the files into the directory you want Qt installed; e.g. C:\Qt\%VERSION% .

Note: The install path must not contain any spaces or Windows specific file system characters.

Step 3: Set the Environment Variables

We recommend creating a desktop link that opens a command prompt with the environment set up similar to the Command Prompt menu entries provided by Visual Studio. This is done by creating an application link passing a .cmd file setting up the environment and the command line option /k (remain open) to cmd.exe .

Assuming the file is called qt5vars.cmd and the Qt folder is called qt-5 and located under C:\qt :

A desktop link can then be created by specifying the command %SystemRoot%\system32\cmd.exe /E:ON /V:ON /k c:\qt\qt5vars.cmd as application and c:\qt\qt-5 as working directory.

Note: Setups for MinGW are similar; they differ only in that the bin folder of the installation should be added to the path instead of calling the Visual Studio setup script. For MinGW, please make sure that no sh.exe can be found in the path, as it affects mingw32-make .

Settings required by the additional libraries (see Qt for Windows — Requirements) should also go this file below the call to the Windows SDK setup script.

Step 4: Build the Qt Library

The default behavior of configure is to create an in-source build of Qt 5. If you want to install Qt 5 to a separate location, you need to specify the command line option -prefix . Alternatively, the command line option -developer-build creates an in-source build for developer usage.

To configure the Qt library for a debug build for your machine, type the following command in the command prompt:

The Configure Options page contains more information about the configure options.

To build Qt using jom, type:

If you do not have jom installed, type:

If an installation prefix was given, type jom install , nmake install or mingw32-make install .

Note: If you later need to reconfigure and rebuild Qt from the same location, ensure that all traces of the previous configuration are removed by entering the build directory and typing nmake distclean before running configure again.

Parallel Builds

jom is a replacement for nmake which makes use of all CPU cores and thus speeds up building.

В© 2020 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.

Читайте также:  Работа с операционной системой семейства windows
Оцените статью