Suggestion regarding GTK+-3.0 tutorial dependency

379 views
Skip to first unread message

Skip Montanaro

unread,
Dec 5, 2021, 4:44:41 PM12/5/21
to The Meson Build System
Meson came up on a discussion of Python's build system:


Having never heard of it before, I thought I'd kick the tires. On my XUbuntu 20.04 system, apt installed version 0.53.2, which I assume should be good enough for a beginner.

The first version of main.c went fine. Then I tried the GTK-embellished version. That didn't work so well. Here's my meson.build file:

project('tutorial', 'c')
gtkdep = dependency('gtk+-3.0')
executable('demo', 'main.c', dependencies : gtkdep)

My first run of meson compile failed (the gtk+-3.0 dependency wasn't satisfied), in part complaining about not finding cmake. So I installed it and tried again. This time it found cmake but still failed on gtk+-3.0:

% meson compile
The Meson build system
Version: 0.53.2
Source dir: /home/skip/tmp/hello
Build dir: /home/skip/tmp/hello/compile
Build type: native build
Project name: tutorial
Project version: undefined
C compiler for the host machine: cc (gcc 9.3.0 "cc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0")
C linker for the host machine: cc ld.bfd 2.34
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found pkg-config: /usr/bin/pkg-config (0.29.1)
Found CMake: /usr/bin/cmake (3.16.3)
Run-time dependency gtk+-3.0 found: NO (tried pkgconfig and cmake)

meson.build:2:0: ERROR: Dependency "gtk+-3.0" not found, tried pkgconfig and cmake

A full log can be found at /home/skip/tmp/hello/compile/meson-logs/meson-log.txt

It took me some head scratching before I realized that pkg-config couldn't find anything out about gtk+-3.0 because I didn't have the relevant GTK dev package installed. Once I figured that out, it built fine.

Just a thought, but since not everybody builds GTK apps and Linux packaging seems so fine-grained these days, I don't think you can assume people reading/running the tutorial will have a GTK dev environment installed. Explaining (in the tutorial) what to do in the case of that one error might be helpful.

Skip Montanaro

Eli Schwartz

unread,
Dec 5, 2021, 5:14:26 PM12/5/21
to meson...@googlegroups.com
On 12/5/21 4:44 PM, Skip Montanaro wrote:
> Meson came up on a discussion of Python's build system:
>
> https://discuss.python.org/t/revisiting-the-case-for-cmake-as-a-primary-cross-major-plats-build-config/11758/10
>
> Having never heard of it before, I thought I'd kick the tires. On my
> XUbuntu 20.04 system, apt installed version 0.53.2, which I assume should
> be good enough for a beginner.


I guess probably the main problem with using meson to build python is
the bootstrap problem. You'd need a python interpreter in order to run
meson and build another python.

https://mesonbuild.com/FAQ.html#but-i-really-want-a-version-of-meson-that-doesnt-use-python

There is a still WIP but getting to be quite featureful port of meson to
C99, which Python itself specifies as a minimum baseline in PEP 7
("Python versions greater than or equal to 3.6 use C89 with several
select C99 features").

It is currently unix-only, but Windows support has been considered. It
is currently not on the roadmap simply because it was primarily
developed on unix and that is where the main development effort is
taking place, but, it has been laid out in a manner that would allow for
future implementation of a VS backend. I'm sure patches would be
welcome, if that was something the CPython core team was interested in.
(Assuming they are interested in switching at all right now.)


> The first version of main.c went fine. Then I tried the GTK-embellished
> version. That didn't work so well. Here's my meson.build file:
>
> project('tutorial', 'c')
> gtkdep = dependency('gtk+-3.0')
> executable('demo', 'main.c', dependencies : gtkdep)
>
> My first run of meson compile failed (the gtk+-3.0 dependency wasn't
> satisfied), in part complaining about not finding cmake. So I installed it
> and tried again. This time it found cmake but still failed on gtk+-3.0:


Ah yes. meson has the concept of multiple *resolvers* for a dependency.
The primary resolver is pkg-config, the secondary, less-supported,
resolver is cmake.

It would be more accurate to say that it looks for a:

- gtk+-3.0.pc
- gtk+-3.0-config.cmake

and it *uses* /usr/bin/pkg-config or /usr/bin/cmake to do so, if it can.
The current tutorial states as follows:


"""
It assumes that you have GTK development libraries available on the
system. On Debian-derived systems such as Ubuntu they can be installed
with the following command:

sudo apt install libgtk-3-dev

It is possible to build the GUI application on other platforms, such as
Windows and macOS, but you need to install the needed dependencies.
"""

Personally, I thought that was a sufficient explanation, so I never
thought to try changing it.

However, I could be biased as I already possessed quite some expertise
on the subject...

Suggestions about the wording are warmly encouraged.


--
Eli Schwartz
Reply all
Reply to author
Forward
0 new messages