Skip to content

AnClark/msys2-qt6base-static

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PKGBUILD for Qt6 Base Static Version on Msys2

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.

Prerequisites

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

Usage

  1. Run Msys2 MinGW64 shell.

    DO NOT USE MSYS SHELL! It uses Msys's POSIX-compatible compilers, which are incompatible with native Win32 environment.

  2. 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
  1. 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.

  1. 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.

Enable Qt6 statically-linking for CMake

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.

Authors

References

rncbc's official repos for Qt6 static build: