showmethekey: Meson fails to build on Debian 12 with `undefined reference to g_ptr_array_sort_values` error

Please can you help, it won’t compile!

$git clone https://github.com/AlynxZhou/showmethekey.git
Cloning into 'showmethekey'...
remote: Enumerating objects: 924, done.
remote: Counting objects: 100% (294/294), done.
remote: Compressing objects: 100% (86/86), done.
remote: Total 924 (delta 242), reused 237 (delta 208), pack-reused 630
Receiving objects: 100% (924/924), 10.28 MiB | 8.12 MiB/s, done.
Resolving deltas: 100% (643/643), done.
david@debian:~/Downloads$ cd showmethekey/
david@debian:~/Downloads/showmethekey$ mkdir build && cd build && meson setup --prefix=/usr . .. && meson compile && meson install
The Meson build system
Version: 1.0.1
Source dir: /home/david/Downloads/showmethekey
Build dir: /home/david/Downloads/showmethekey/build
Build type: native build
Project name: showmethekey
Project version: 1.11.1
C compiler for the host machine: cc (gcc 12.2.0 "cc (Debian 12.2.0-14) 12.2.0")
C linker for the host machine: cc ld.bfd 2.40
Host machine cpu family: x86_64
Host machine cpu: x86_64
Configuring config.h using configuration
Found pkg-config: /usr/bin/pkg-config (1.8.1)
Run-time dependency libevdev found: YES 1.13.0
Run-time dependency libudev found: YES 252
Run-time dependency libinput found: YES 1.22.1
Run-time dependency threads found: YES
Run-time dependency gtk4 found: YES 4.8.3
Run-time dependency libadwaita-1 found: YES 1.2.2
Run-time dependency x11 found: YES 1.8.4
Run-time dependency glib-2.0 found: YES 2.74.6
Run-time dependency json-glib-1.0 found: YES 1.6.6
Run-time dependency gio-2.0 found: YES 2.74.6
Run-time dependency cairo found: YES 1.16.0
Run-time dependency pango found: YES 1.50.12
Run-time dependency xkbcommon found: YES 1.5.0
Run-time dependency xkbregistry found: YES 1.5.0
Found pkg-config: /usr/bin/pkg-config (1.8.1)
Program glib-compile-resources found: YES (/usr/bin/glib-compile-resources)
Program glib-mkenums found: YES (/usr/bin/glib-mkenums)
Program glib-mkenums found: YES (/usr/bin/glib-mkenums)
Program msgfmt found: YES (/usr/bin/msgfmt)
Program msginit found: YES (/usr/bin/msginit)
Program msgmerge found: YES (/usr/bin/msgmerge)
Program xgettext found: YES (/usr/bin/xgettext)
Configuring one.alynx.showmethekey.policy using configuration
Configuring one.alynx.showmethekey.desktop using configuration
Build targets in project: 10

showmethekey 1.11.1

  User defined options
    prefix: /usr

Found ninja-1.11.1 at /usr/bin/ninja
INFO: autodetecting backend as ninja                                                                
INFO: calculating backend command to run: /usr/bin/ninja
[9/19] Compiling C object showmethekey-gtk/showmethekey-gtk.p/smtk-keymap-list.c.o
../showmethekey-gtk/smtk-keymap-list.c: In function ‘smtk_keymap_list_sort’:
../showmethekey-gtk/smtk-keymap-list.c:261:9: warning: implicit declaration of function ‘g_ptr_array_sort_values’; did you mean ‘g_ptr_array_sort’? [-Wimplicit-function-declaration]
  261 |         g_ptr_array_sort_values(keymap_list->items, _compare);
      |         ^~~~~~~~~~~~~~~~~~~~~~~
      |         g_ptr_array_sort
[19/19] Linking target showmethekey-gtk/showmethekey-gtk
FAILED: showmethekey-gtk/showmethekey-gtk 
cc  -o showmethekey-gtk/showmethekey-gtk showmethekey-gtk/showmethekey-gtk.p/meson-generated_.._smtk-resources.c.o showmethekey-gtk/showmethekey-gtk.p/meson-generated_.._smtk-enum-types.c.o showmethekey-gtk/showmethekey-gtk.p/main.c.o showmethekey-gtk/showmethekey-gtk.p/smtk-app.c.o showmethekey-gtk/showmethekey-gtk.p/smtk-app-win.c.o showmethekey-gtk/showmethekey-gtk.p/smtk-keys-win.c.o showmethekey-gtk/showmethekey-gtk.p/smtk-keys-area.c.o showmethekey-gtk/showmethekey-gtk.p/smtk-keys-emitter.c.o showmethekey-gtk/showmethekey-gtk.p/smtk-keys-mapper.c.o showmethekey-gtk/showmethekey-gtk.p/smtk-keymap-list.c.o showmethekey-gtk/showmethekey-gtk.p/smtk-event.c.o -Wl,--as-needed -Wl,--no-undefined -Wl,--start-group /usr/lib/x86_64-linux-gnu/libgtk-4.so /usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so /usr/lib/x86_64-linux-gnu/libpango-1.0.so /usr/lib/x86_64-linux-gnu/libharfbuzz.so /usr/lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so /usr/lib/x86_64-linux-gnu/libcairo-gobject.so /usr/lib/x86_64-linux-gnu/libcairo.so /usr/lib/x86_64-linux-gnu/libgraphene-1.0.so /usr/lib/x86_64-linux-gnu/libgio-2.0.so /usr/lib/x86_64-linux-gnu/libgobject-2.0.so /usr/lib/x86_64-linux-gnu/libglib-2.0.so /usr/lib/x86_64-linux-gnu/libadwaita-1.so /usr/lib/x86_64-linux-gnu/libX11.so /usr/lib/x86_64-linux-gnu/libjson-glib-1.0.so /usr/lib/x86_64-linux-gnu/libxkbcommon.so /usr/lib/x86_64-linux-gnu/libxkbregistry.so -Wl,--end-group
/usr/bin/ld: showmethekey-gtk/showmethekey-gtk.p/smtk-keymap-list.c.o: in function `smtk_keymap_list_sort':
/home/david/Downloads/showmethekey/build/../showmethekey-gtk/smtk-keymap-list.c:261: undefined reference to `g_ptr_array_sort_values'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.

About this issue

  • Original URL
  • State: closed
  • Created 8 months ago
  • Comments: 20 (11 by maintainers)

Commits related to this issue

Most upvoted comments

And without the & a segmentation fault is thrown as soon as the application starts.

Your change is correct on syntax but wrong on logic, it passes you address of address of the item, and you then require address of address of address of the item, what’s correct is de-reference the pointer to get the address of the item, so just use *.

This patch is what you need to build it on older GLib without g_ptr_array_sort_values():

diff --git a/showmethekey-gtk/smtk-keymap-list.c b/showmethekey-gtk/smtk-keymap-list.c
index e6566a5..ad3a4d6 100644
--- a/showmethekey-gtk/smtk-keymap-list.c
+++ b/showmethekey-gtk/smtk-keymap-list.c
@@ -242,9 +242,9 @@ void smtk_keymap_list_append(SmtkKeymapList *keymap_list, const char *layout,
 static int _compare(gconstpointer a, gconstpointer b)
 {
        const char *name1 =
-           smtk_keymap_item_get_name(SMTK_KEYMAP_ITEM((gpointer)a));
+         smtk_keymap_item_get_name(SMTK_KEYMAP_ITEM(*(gpointer *)a));
        const char *name2 =
-           smtk_keymap_item_get_name(SMTK_KEYMAP_ITEM((gpointer)b));
+         smtk_keymap_item_get_name(SMTK_KEYMAP_ITEM(*(gpointer *)b));
        // Most people use US (QWERTY) layout, so make it first to be the
        // default value.
        if (g_strcmp0(name1, "us") == 0)
@@ -258,7 +258,7 @@ void smtk_keymap_list_sort(SmtkKeymapList *keymap_list)
 {
        g_return_if_fail(keymap_list != NULL);
 
-   g_ptr_array_sort_values(keymap_list->items, _compare);
+ g_ptr_array_sort(keymap_list->items, _compare);
        g_list_model_items_changed(G_LIST_MODEL(keymap_list), 0,
                                   keymap_list->items->len,
                                   keymap_list->items->len);