Installing gtk4 for testing on /opt

I do intent to add a few more examples for GTK4 to the Nim bindings readme, as we have only one currently.

Unfortunately Gentoo Linux still have to GTK4 for testing. But maybe one year ago I already installed gtk 3.96 on /opt, see

I tried to remember the steps. Most difficult for me is finding the page with the instructions, but it was saved in the old forum post. Then I followed the instructions, that is

$ cat ~/gtk4_install 
rm -rf /opt/gtk
mkdir /opt/gtk

rm -rf gtk
git clone

LDFLAGS="-L/opt/gtk/lib64" # caution: lib64 for recent gentoo linux
PKG_CONFIG_PATH="/opt/gtk/lib64/pkgconfig" # caution: lib64 for recent gentoo linux

LD_LIBRARY_PATH="/opt/gtk/lib64" # caution: lib64

cd gtk

meson --prefix /opt/gtk builddir

cd builddir
ninja install

Seems to work fine, I can launch gtk4-demo with

$ GSETTINGS_SCHEMA_DIR=/opt/gtk/share/glib-2.0/schemas /opt/gtk/bin/gtk4-demo

and it works well.

But during install I got messages like

Found ninja-1.10.0 at /usr/bin/ninja
[3/1583] Compiling C object 'gdk/wayland/cursor/4b92630@@wayland+cursor@sta/xcursor.c.o'.
cc1: warning: /opt/gtk/include: No such file or directory [-Wmissing-include-dirs]
[6/1583] Compiling C object 'gdk/wayland/cursor/4b92630@@wayland+cursor@sta/wayland-cursor.c.o'.
cc1: warning: /opt/gtk/include: No such file or directory [-Wmissing-include-dirs]

I guess that is because /opt/gtk/include does not exists before the final ninja install step.
So maybe I did something wrong?

And final question, what is the recommended strategy for linux distros about gtk4. Should distros provide already gtk4 for testing, or better not? I think some do, but gentoo does not. I do consider pushing gentoo maintainers to provide it, as manually installation is some effort.

I would expect the following steps to be sufficient for installing GTK under /opt:

meson --prefix /opt/gtk builddir
ninja -C builddir
ninja -C builddir install

Then, if you want to link against it, you should only need to set PKG_CONFIG_PATH=/opt/gtk/lib/pkgconfig and the build tool should find the appropriate compiler and linker flags.

And for running apps add /opt/gtk/share to XDG_DATA_DIRS.

Thanks for that hint.

In the older thread which I refered at the top someone wrote:

That should work! Anyway I suggest using jhbuild or buildstream for parallel installations, so you know that >everything is set up correctly.

Is that jhbuild really a better option? And is there a description available?

jhbuild will take care of calling the build tools and installing the projects for you and it is still the recommend method for building GNOME projects as far as I am aware. You can read more about it on

Buildstream aims to replace it but I have not tried it

Personally, I prefer Nix, which also allows you to do similar things but has a wider scope as a package manager:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.