-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Cross-Platform Development with Qt 6 and Modern C++
By :
If you want to build the framework and tools yourself or experiment with the latest unreleased code, then you can build Qt from the source code. If you're going to develop a specific Qt version from the source, then you can download the Qt 6 source code from the official releases link, as shown here: https://download.qt.io/official_releases/qt/6.0/.
If you are a commercial customer, then you can download the Source Packages from your Qt account portal. Platform-specific building instructions are discussed in the upcoming subsections.
You can also clone from the GitHub repository, and check out the desired branch. At the time of authoring this book, the Qt 6 branch remained inside the Qt 5 super module. You can clone the repository from the following link: git://code.qt.io/qt/qt5.git.
The qt5.git repository may get renamed to qt.git in the future for maintainability. Please refer to the QTQAINFRA-4200 Qt ticket. Detailed instructions on how to build Qt from Git can be found at the following link: https://wiki.qt.io/Building_Qt_6_from_Git.
Ensure that you install the latest versions of Git, Perl, and Python on your machine. Make sure there is a working C++ compiler before proceeding to the platform-specific instructions in the next section.
To install Qt 6 on Windows from source code, follow these next steps:
qt-everywhere-src--%VERSION%.zip, where %VERSION% is the latest version (such as qt-everywhere-src-6.0.3.zip). Please note that suffixes such as -everywhere-src- may get removed in the future.C:\Qt6\src.CMake, ninja, Perl, and Python to your PATH environment variable.configure.bat script in the source directory.>cmake --build . –parallel
>cmake --install .
Your Windows machine is now ready to use Qt.
To understand more about the configure options, visit the following link:
https://doc.qt.io/qt-6/configure-options.html
Detailed build instructions can be found at the following link:
https://doc.qt.io/qt-6/windows-building.html
To build the source package on Linux distributions, run the following set of instructions on your terminal:
qt-everywhere-src--%VERSION%.tar.xz, where %VERSION% is the latest version (such as qt-everywhere-src-6.0.3.tar.xz). Please note that suffixes such as -everywhere-src- may get removed in the future./qt6, as illustrated in the following code snippet:$ cd /qt6 $ tar xvf qt-everywhere-opensource-src-%VERSION%.tar.xz $ cd /qt6/qt-everywhere-opensource-src-%VERSION%
./configure script in the source directory, as illustrated in the following code snippet:$ ./configure
$ cmake --build . --parallel $ cmake --install .
.profile (if your shell is bash, ksh, zsh, or sh), add the following lines of code:PATH=/usr/local/Qt-%VERSION%/bin:$PATH export PATH
In .login (if your shell is csh or tcsh), add the following line of code:
setenv PATH /usr/local/Qt-%VERSION%/bin:$PATH
If you use a different shell, modify your environment variables accordingly. Qt is now ready to be used on your Linux machine.
Detailed building instructions for Linux/X11 can be found at the following link:
https://doc.qt.io/qt-6/linux-building.html
Qt has a dependency on Xcode. To install Qt on your Mac, you will need Xcode installed on your machine. If you don't have Xcode installed on your machine, then you may proceed to install Xcode's Command Line Tools:
$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
$ cd /qt6 $ tar xvf qt-everywhere-opensource-src-%VERSION%.tar $ cd /qt6/qt-everywhere-opensource-src-%VERSION%
./configure script in the source directory, as illustrated in the following code snippet:$ ./configure
make command, as follows:$ make
-prefix is outside the build directory, then type the following lines to install the library:$ sudo make -j1 install
.profile (if your shell is bash), add the following lines of code:PATH=/usr/local/Qt-%VERSION%/bin:$PATH export PATH
In .login (if your shell is csh or tcsh), add the following line of code:
setenv PATH /usr/local/Qt-%VERSION%/bin:$PATH
Your machine is now ready for Qt programming.
Detailed building instructions for macOS can be found here:
https://doc.qt.io/qt-6/macos-building.html
In this section, we learned how to install Qt from source on your favorite platform. Now, let's summarize our learning.