I've made Quasi-MSYS2, which helps download MSYS2 packages on Linux.
sudo apt install make wget tar zstd gpg
git clone https://github.com/HolyBlackCat/quasi-msys2
cd quasi-msys2/
make install _gtk4 # equivalent to `make install mingw-w64-x86_64-gtk4`
This downloads GTK4 to the current directory (./root/mingw64/
) for you to use.
But there's a problem: MinGW comes in different flavors, and the flavors provided by MSYS2 may or may not be compatible with the flavor provided by Ubuntu.
The recommended build method doesn't depend on external MinGW. Instead I suggest using Clang, which can work with any MinGW flavor, if provided the right libraries (which we download from MSYS2).
sudo apt install wine # Optional.
# Install latest Clang
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh
rm llvm.sh
# Install more packages
make install _gcc _gdb # We won't be using GCC, but we need libraries that come with it.
# Opens a new shell with the right environment variables configured.
env/shell.sh
Then, testing on Hello World from here:
# Notice `pkg-config` picking up the correct libraries.
win-clang++ hello_world.cpp `pkg-config --cflags --libs gtk4`
# This opens the app in Wine:
./a.exe