Building GTK on Ubuntu 22.04.1 LTS

harfbuzz| Program check-static-inits.py found: YES (/home/prusso/gtk/subprojects/harfbuzz/src/check-static-inits.py)
harfbuzz| Program check-symbols.py found: YES (/home/prusso/gtk/subprojects/harfbuzz/src/check-symbols.py)
harfbuzz| Program run-tests.py found: YES (/home/prusso/gtk/subprojects/harfbuzz/test/shape/run-tests.py)
harfbuzz| Program run-tests.py found: YES (/home/prusso/gtk/subprojects/harfbuzz/test/subset/run-tests.py)
harfbuzz| Program run-repack-tests.py found: YES (/home/prusso/gtk/subprojects/harfbuzz/test/subset/run-repack-tests.py)
harfbuzz| Program run-shape-fuzzer-tests.py found: YES (/home/prusso/gtk/subprojects/harfbuzz/test/fuzzing/run-shape-fuzzer-tests.py)
harfbuzz| Program run-subset-fuzzer-tests.py found: YES (/home/prusso/gtk/subprojects/harfbuzz/test/fuzzing/run-subset-fuzzer-tests.py)
harfbuzz| Program run-draw-fuzzer-tests.py found: YES (/home/prusso/gtk/subprojects/harfbuzz/test/fuzzing/run-draw-fuzzer-tests.py)
harfbuzz| Program gtkdoc-scan found: NO
harfbuzz| Message: Not building documentation as gtk-doc was not found
harfbuzz| Configuring config.h using configuration
harfbuzz| Build targets in project: 585
harfbuzz| NOTICE: Future-deprecated features used:
harfbuzz| * 0.56.0: {‘meson.source_root’}
harfbuzz| Subproject harfbuzz finished.

pango| Dependency harfbuzz from subproject subprojects/harfbuzz found: YES 5.2.0
pango| Run-time dependency fontconfig found: NO (tried pkgconfig and cmake)
pango| Run-time dependency fontconfig found: NO (tried pkgconfig and cmake)
pango| Looking for a fallback subproject for the dependency fontconfig

subprojects/pango/meson.build:306:2: ERROR: Subproject “subprojects/fontconfig” required but not found.

A full log can be found at /home/prusso/gtk/_build/meson-logs/meson-log.txt
prusso@Dragon:~/gtk$ cd _build
prusso@Dragon:~/gtk/_build$ ninja
ninja: error: loading ‘build.ninja’: No such file or directory
prusso@Dragon:~/gtk/_build$

I followed the instructions from:

Does anyone know why Ninja is asking for this build file or if one should be generated or otherwise placed into the build system some way? Is there some reference to describe in more detail how to get GTK to finish building on ubuntu:

No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04.1 LTS
Release: 22.04
Codename: jammy
prusso@Dragon:~/gtk/_build$ ^C

You need to install the fontconfig devel package.

There were a number of packages left to install the reason why ninja did not work is that ~/gtk-master/_build had to be the current path before entering “ninja” to the terminal. That is why the ninja build file was not found yet.

You don’t need that at all. You can either use ninja -C _build or, more appropriately, use Meson’s compile subcommand, e.g. meson compile -C _build.

No, the reason why the build.ninja file was not found was that meson setup failed:

subprojects/pango/meson.build:306:2: ERROR: Subproject “subprojects/fontconfig” required but not found.

The meson setup step must succeed in order to be able to build GTK.

OK Thank you so much for your help. So with the latest:

git clone GitHub - GNOME/gtk: Read-only mirror of https://gitlab.gnome.org/GNOME/gtk
cd gtk
meson.py _build .
ninja -C _build
cd _build
sudo ~/ninja-master/ninja install

Seems to work with the latest versions of cmake ninja and meson that I downloaded the current repositories to.

I would recommend installing Ninja from your own distribution’s repository:

apt install ninja-build

Then install Meson using pip:

pip3 install --user meson

Then you can build GTK with:

meson setup _build
meson compile -C _build
sudo meson install -C _build

BUT you are going to install GTK4 from Git in /usr/local, which means you’ll have to change your environment in order to build code that uses GTK4.

At this point the question would be: what are you trying to achieve, and why are you building GTK from Git?

The reason why I would like to compile GTK from source is to have the latest version. As far as changing the environment to build GTK4 code with the newly installed source ball is that something you can describe for me how to do it?

I likely wasn’t clear: why would you want the latest version? To develop your application? To run GTK4 applications?

The reason I want the source code is not for use with existing applications it is for setting up VS Code with the latest GTK library for the development of C++ applications. Any code that gets written on an installation of GTK4 just for example would be more out of date and as GTK changes as an API they would be less likely to compile the further behind that they are. Is it possible to document how to change the environment for people that would like to use the latest source code to do this on the open stack

I have a new folder “/usr/include/gtk-4.0” but at this time I am not really sure how to get the environment changed so that VS Code can recognize that GTK is there and were to access all of its libraries.

Really where I am stuck still is coming out of VS Code’s window I have:

Starting build...
/usr/bin/g++ -fdiagnostics-color=always -g /home/phillip/helloworld/.vscode/main.cpp -o /home/phillip/helloworld/.vscode/main -pthread -pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/harfbuzz -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -lharfbuzz -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0
In file included from /home/phillip/helloworld/.vscode/main.cpp:1:
/usr/include/gtk-4.0/gtk/gtk.h:30:10: fatal error: gtk/css/gtkcss.h: No such file or directory
   30 | #include <gtk/css/gtkcss.h>
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.

Build finished with error(s).

So there is trouble finding gtkcss.h but that is really all I know beyond that it does build and also debug if one uses CMake. I would really like to get things going just with g++. Is it possible maybe to know why things are stopping I have the squiggly lines still at "#include <gtk-4.0/gtk/gtk.h> still even though the file does seem to exist on the filesystem.

So for the benefit of others I guess I should say that if you set in launch.json the args: property in a way that VS Code accepts as the same as at terminal it does build and also start a debug session however the place that I am stuck still is why the squiggly lines in vs code at “#include <gtk-4.0/gtk/gtk.h>” which happens to be the first line of main.cpp don’t seem to go away? I tried setting all the include folder of cpp_properties_json but for some reason still the squiggly lines don’t go away even though everything seems to be working all the way. I also tried setting permissions on /usr/include/gtk-4.0 to 777 to no avail. Is anyone else aware of this thing how to fix it?

I seem to get the described behavior on Ubuntu 22.04.1 LTS unvirtualized and also in Microsoft's WSL2.

So far the last few problems VS Code has are a graphene-config.h that could not be found. I looked in the file system but there does not seem to be one yet I found it as part of a graphene installation.

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