I'm learning GTK, and I'm trying to get its hello world
example program compile on my ubuntu 24.04 system, but I got this following message:
> gcc $(pkg-config --cflags gtk4) -o hello-world-gtk hello-world-gtk.c $(pkg-config --libs gtk4)
Package gtk4 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk4.pc'
to the PKG_CONFIG_PATH environment variable
Package 'gtk4', required by 'virtual:world', not found
Package gtk4 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk4.pc'
to the PKG_CONFIG_PATH environment variable
Package 'gtk4', required by 'virtual:world', not found
hello-world-gtk.c:1:10: fatal error: gtk/gtk.h: No such file or directory
1 | #include <gtk/gtk.h>
| ^~~~~~~~~~~
compilation terminated.
I believe I have installed gtk packages because I ran this installation command and got the following message:
> sudo apt install libgtk-4-1
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libgtk-4-1 is already the newest version (4.14.2+ds-1ubuntu1).
libgtk-4-1 set to manually installed.
The following packages were automatically installed and are no longer required:
linux-headers-6.8.0-50 linux-headers-6.8.0-50-generic
linux-image-6.8.0-50-generic linux-modules-6.8.0-50-generic
linux-modules-extra-6.8.0-50-generic linux-tools-6.8.0-50
linux-tools-6.8.0-50-generic python3-netifaces
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 127 not upgraded.
What is wrong here?
Ubuntu splits development files into separate packages, like libgtk-4-1
has a libgtk-4-dev
.
You’ll likely need more dev packages along the way.