Cross-Compiling GTK for Windows 2026

GTK is at version 4.22.4 (stable) and 3.24.52 (old-stable) as of 2026. The build system is now Meson instead of autotools. Fedora maintainers keep the mingw-w64 cross-compiler toolchain and GTK packages up to date.

You have two options: . # Install pre-built mingw64 packages and compile your app against them (easiest) . # Cross-compile everything from source for the latest features

Option 1 — Pre-Built mingw64 Packages

Fedora ships mingw64 cross-compiled packages for both GTK4 and GTK3. Install the toolchain and libraries:

sudo dnf install mingw64-gcc mingw64-gcc-c++ mingw64-binutils mingw64-filesystem
sudo dnf install mingw64-gtk4 mingw64-gtk4-update-icon-cache
# or for GTK3: mingw64-gtk3
sudo dnf install mingw64-glib2 mingw64-cairo mingw64-pango mingw64-gdk-pixbuf
sudo dnf install mingw64-libepoxy mingw64-pixman mingw64-libpng mingw64-zlib
sudo dnf install mingw64-gettext mingw64-fontconfig mingw64-harfbuzz

Compile your application against the cross toolchain:

mingw64-env
export PKG_CONFIG_PATH=/usr/x86_64-w64-mingw32/sys-root/mingw/lib/pkgconfig
x86_64-w64-mingw32-gcc $(pkg-config --cflags gtk4) -o app.exe app.c $(pkg-config --libs gtk4)

Test under Wine:

wine app.exe

Option 2 — Build from Source

For the absolute latest GTK or custom patches, cross-compile from source. The build order is the same as before: GLib, Cairo, Pango, then GTK. Each now uses Meson.

Environment

mingw64-env
export MINGW=/usr/x86_64-w64-mingw32/sys-root/mingw
export PREFIX=$HOME/.wine/drive_c/gtk
export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$MINGW/lib/pkgconfig"
export CPPFLAGS="-I$PREFIX/include -I$MINGW/include"
export LDFLAGS="-L$PREFIX/lib -L$MINGW/lib"
export PATH="$PREFIX/bin:$PATH"
export LD_LIBRARY_PATH="$PREFIX/lib"

Glib

cd glib
meson setup --prefix=$PREFIX --cross-file=/usr/share/mingw/toolchain-mingw64.meson builddir
meson configure builddir -Dtests=false -Dinstalled_tests=false -Dglib_assert=false
meson compile -Cbuilddir
meson install -Cbuilddir
cd ..

The toolchain-mingw64.meson file ships with Fedora's mingw64-filesystem package. It sets the cross-compiler, host tuple, and sysroot automatically.

Cairo

cd cairo
meson setup --prefix=$PREFIX --cross-file=/usr/share/mingw/toolchain-mingw64.meson builddir
meson configure builddir -Dtests=disabled -Dxlib=disabled -Dfontconfig=enabled
meson compile -Cbuilddir
meson install -Cbuilddir
cd ..

Pango

cd pango
meson setup --prefix=$PREFIX --cross-file=/usr/share/mingw/toolchain-mingw64.meson builddir
meson configure builddir -Dtests=false -Dintrospection=disabled
meson compile -Cbuilddir
meson install -Cbuilddir
cd ..

GdkPixbuf

cd gdk-pixbuf
meson setup --prefix=$PREFIX --cross-file=/usr/share/mingw/toolchain-mingw64.meson builddir
meson configure builddir -Dtests=false -Dgio_sniffing=false
meson compile -Cbuilddir
meson install -Cbuilddir
cd ..

Pixman

cd pixman
meson setup --prefix=$PREFIX --cross-file=/usr/share/mingw/toolchain-mingw64.meson builddir
meson configure builddir -Dtests=disabled
meson compile -Cbuilddir
meson install -Cbuilddir
cd ..

Libepoxy

cd libepoxy
meson setup --prefix=$PREFIX --cross-file=/usr/share/mingw/toolchain-mingw64.meson builddir
meson compile -Cbuilddir
meson install -Cbuilddir
cd ..

GTK4

cd gtk
meson setup --prefix=$PREFIX --cross-file=/usr/share/mingw/toolchain-mingw64.meson builddir
meson configure builddir -Dbuild-tests=false -Dbuild-examples=false -Dbuild-demos=false \
  -Dintrospection=disabled -Dmedia-gstreamer=disabled -Dvulkan=disabled
meson compile -Cbuilddir
meson install -Cbuilddir
cd ..

Add -Dx11-backend=false -Dwayland-backend=false -Dwin32-backend=true to force the Win32 backend explicitly.

Testing on Wine

Register the GTK directory in Wine's registry:

cat << 'REG' | wine regedit -
[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment]
"GTKDIR"="C:\\gtk"
"PATH"="%GTKDIR%\\bin;%PATH%"
REG

Configure GTK modules:

wine gtk-query-immodules-4.0.exe > $PREFIX/lib/gtk-4.0/4.0.0/immodules.cache
wine gdk-pixbuf-query-loaders.exe > $PREFIX/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache

Copy the Adwaita icon theme:

cp -r /usr/x86_64-w64-mingw32/sys-root/mingw/share/icons/Adwaita $PREFIX/share/icons/
wine gtk4-demo.exe

What Changed

Meson replaces autotools.* The old ./autogen.sh && ./configure && make chain is replaced by meson setup && meson compile && meson install. GTK4 is the stable branch.* GTK 3.24.x is still maintained but development is on GTK4 and GTK5 planning. Fedora ships cross .meson toolchain files.* No more hand-rolling $OPTS with 20 configure flags — the toolchain file sets --host, --build, sysroot, and compiler paths. Pre-built mingw64 packages work.* Most users don't need to build from source at all. PyGObject cross-compilation* is still difficult. GObject introspection support for cross targets remains experimental. For Python GTK apps on Windows, the MSYS2 distribution is the recommended approach.

Sources

* GTK build documentation * Meson cross-compilation guide * Fedora mingw64-gtk4 package * Fedora mingw64-gtk3 package * GTK homepage

CCBY Copyright © 2026 Henry Kroll III, thenerdshow.com This web page is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.