Alternatively, you can install the development package for gdk-pixbuf that comes with your distribution; GTK does not require a bleeding edge version of gdk-pixbuf, and the subproject is mostly there for building GTK on macOS and Windows.
Alternatively, you can install the development package for gdk-pixbuf that comes with your distribution
Thanks! For pixbuf that did the trick, but unfortunately for pango the version provided by my system was too old for the build requirements. I think I don’t want to disable introspection altogether because I’m going to use this from python. What would be the best way to proceed given that I already have the pango submodule?
I think this is an issue between gobject-introspection and Meson, when using subprojects.
A solution that does not involve disabling introspection is to use jhbuild. That will install all the dependencies in a separate prefix and avoid subprojects altogether.
Ok, I managed to build gtk4 in two different ways according to your suggestions:
First build pango and graphene from the subprojects directory and add them to PKG_CONFIG_PATH and XDG_DATA_DIRS, then build gtk4 itself.
Use jhbuild. This tool is very convenient! It’s the first time I use it. The complexity of the build was quite impressive, even gstreamer bad plugins were built. I set shallow_clone = True in jhbuildrc to avoid huge clones. I had to manually install libudev-dev because it wasn’t automatically installed. Other than that, everything went ok.
After the build I set LD_LIBRARY_PATH and XDG_DATA_DIRS:
import gi
gi.require_version("Gtk", "4.0")
from gi.repository import Gtk
I get:
File "/usr/lib/python3/dist-packages/gi/importer.py", line 145, in load_module
dynamic_module = load_overrides(introspection_module)
File "/usr/lib/python3/dist-packages/gi/overrides/__init__.py", line 118, in load_overrides
override_mod = importlib.import_module(override_package_name)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/usr/lib/python3/dist-packages/gi/overrides/Gtk.py", line 168, in <module>
class Container(Gtk.Container, Widget):
File "/usr/lib/python3/dist-packages/gi/module.py", line 123, in __getattr__
raise AttributeError("%r object has no attribute %r" % (
AttributeError: 'gi.repository.Gtk' object has no attribute 'Container'
GIR files seem to be correctly generated at /home/carlos/jhbuild/install/share/gir-1.0/. I also tried putting ~/jhbuild/install/share at the beginning of XDG_DATA_DIRS, to no avail.
Do you have any idea about what may be happening? Do I need an updated version of python gi ? There are some python modules in ~/jhbuild/install/lib/python3.8/site-packages but gi is not one of them.
Ok, that did it, thanks! I had to first install pycairo in the venv in order to build and install pyobject, I think build_ext required it, is that normal?