How To Install GTk4 On Linux

GTK4 is the latest version of the GNOME Toolkit, a powerful framework used to build modern graphical applications on Linux. Many popular apps (and desktop environments like GNOME) rely on GTK, and GTK4 brings improved performance, better rendering, and modern UI features.

In this guide, I’ll walk you through installing GTK4 on the most common Linux distributions.

What Is GTK4?

GTK (GIMP Toolkit) is a cross-platform library for creating graphical user interfaces. GTK4 is a major upgrade over GTK3 and includes:

  • GPU-accelerated rendering

  • Improved animations and input handling

  • Modern UI patterns

  • Better support for Wayland

GTK4 is commonly used with C, but also works with Python, Rust, Vala, and more.

Check If GTK4 Is Already Installed

Before installing, check if GTK4 is already on your system:

pkg-config –modversion gtk4

If GTK4 is installed, you’ll see a version number (for example: 4.12.5).
If not, you’ll get an error — that’s normal.

Install GTK4 on Ubuntu / Debian

GTK4 is available in the official repositories.

Update your system

sudo apt update

Install GTK4 development files

sudo apt install libgtk-4-dev

This installs:

GTK4 libraries

Headers needed to compile GTK apps

pkg-config files

Install GTK4 on Fedora

Fedora ships with GTK4 by default.

sudo dnf install gtk4-devel

Install GTK4 on Arch Linux / Manjaro

On Arch-based systems:

sudo pacman -S gtk4

Install GTK4 on openSUSE

sudo zypper install gtk4-devel
 

Verify the Installation

After installing, confirm everything works:

pkg-config –cflags gtk4
pkg-config –libs gtk4

If these commands return output (and not errors), GTK4 is installed correctly.

Bonus: Example App

Create a file called test.c:

#include <gtk/gtk.h>

static void activate(GtkApplication *app, gpointer user_data) {
GtkWidget *window = gtk_application_window_new(app);
gtk_window_set_title(GTK_WINDOW(window), “GTK4 Test”);
gtk_window_set_default_size(GTK_WINDOW(window), 400, 300);
gtk_window_present(GTK_WINDOW(window));
}

int main(int argc, char **argv) {
GtkApplication *app;
int status;

app = gtk_application_new(“com.example.GtkTest”, G_APPLICATION_DEFAULT_FLAGS);
g_signal_connect(app, “activate”, G_CALLBACK(activate), NULL);
status = g_application_run(G_APPLICATION(app), argc, argv);
g_object_unref(app);

return status;
}

Compile it with:

gcc test.c -o test `pkg-config –cflags –libs gtk4`

Permissions:

chmod +x test.c

Run it:

./test
 
If a window appears, GTK4 is working
 

Common Problems and Fixes

Package gtk4 was not found

Make sure libgtk-4-dev / gtk4-devel is installed

Check that pkg-config is installed

App runs but no window appears

Make sure you’re calling gtk_window_present()

Ensure you’re using GTK4 functions (GTK3 code won’t always work)

Leave a Reply

Your email address will not be published. Required fields are marked *

Sign-Up To Stay In The Loop

0
 
characters