Here's the Msys2 PKGBUILD for Qt6 Base, statically-linked version. Initially this is for compiling Rui Nuno Capela's Vee One Suite on my computer.
A static version of Qt6 can make your applications more portable, without copying a bundle of Qt6 libraries. By default Qt6 static version is also unavailable on Msys2, you need to build it from scratch as well.
Now, this PKGBUILD will help you out. It generates a Pacman package, just make it portable and manageable.
You need to install those packages to build Qt6:
pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja
-
Run Msys2 MinGW64 shell.
DO NOT USE MSYS SHELL! It uses Msys's POSIX-compatible compilers, which are incompatible with native Win32 environment.
-
Clone this repo. Make sure that you won't put other files in
PKGBUILD
's directory.
git clone https://github.com/AnClark/msys2-qt6base-static ~/msys2-qt6base-static
- Build package.
cd ~/msys2-qt6base-static/
makepkg -f
When done, you'll get a package file: mingw-w64-x86_64-qtbase6-static-6.x.x-x86_64.pkg.tar.zst
. 6.x.x
should be the actual Qt version.
- Install package.
pacman -U mingw-w64-x86_64-qtbase6-static-6.x.x-x86_64.pkg.tar.zst
Finally, Qt6 base static library will be installed into /opt/qt6-static
.
There's also an initialization script within this package. If your project uses CMake, you can invoke it before configuring with CMake:
source /opt/qt6-static/bin/qt6-static-env.sh
Including this script will configure some necessary environment variables to let CMake choose static version of Qt6 library.
- Original author: Rui Nuno Capela (rncbc)
- Maintainer: AnClark
rncbc's official repos for Qt6 static build: