Build Qt 6 with VC-LTL
Last week I talked with my friend wangwenx190 for some advice on compiling Qt 6 source code with the VC-LTL toolchain. After several hours of discussions, I made a lot of progress, but the –debug-and-release mode of Qt 6’s configure.bat didn’t work, and I was stuck because I don’t use CMake very often. A few days later, my friend gave VC-LTL a PR to resolve the issue, so I summarized the approach in this article.
Read here for the Chinese version of this article if you are not good at English. (Translation: 如果你不擅长英文,可以点击本段话中的链接阅读中文版)
This article assumes that you have already configured a basic environment for compiling Qt 6 source code, because the main purpose of this article is to describe how to compile Qt 6 source code with VC-LTL to make your compiled Qt 6 binaries only rely on the Windows built-in msvcrt.dll
or ucrtbase.dll
as the C runtime library for achieving the goal of deploying without additional MSVC runtime library.
First you need to download the latest version of VC-LTL binary package from https://github.com/Chuyu-Team/VC-LTL5/releases ( the latest version of VC-LTL is named VC-LTL-5.0.3-Beta1-Binary.7z
at the time of writing this article for example) and Unzip the package to a directory with only English characters ( C:\Tools\VC-LTL
in this example) and run Install.cmd
in the extracted directory to register the directory of VC-LTL’s toolchain to the system.
Then modify config/config.cmake
in the VC-LTL toolchain directory according to wangwenx190’s PR for VC-LTL, i.e. find line 19 in that file. If you find the following, just remove them and save the file.
1 |
|
Then copy the VC-LTL helper for cmake.cmake
file from the VC-LTL toolchain directory to the qtbase/cmake/
subdirectory of the Qt source code directory and rename it to VC-LTL.cmake
, and add the following to the end of qtbase/cmake/QtBuild.cmake
and save the below content.
1 |
|
Then you can follow the official Qt 6 build tutorial to build the Qt 6 binaries with the VC-LTL toolchain, with my Qt 6 build commands listed by the way.
1 |
|
I hope everyone has a smooth experience with Qt 6, thanks for reading.
See also
Windows Research NotesUnless otherwise stated, all articles in this blog follow the CC BY-NC-ND 4.0 license, please indicate the source for reprinting!