1

OS: Linux Mint 21.1 x86_64

As stated in GTK's official site (https://www.gtk.org/docs/installations/linux/) I downloaded the dev package for my distribution as:

sudo apt-get install libgtk-4-dev

The installation completed successfully and installed the contents to the folder below:

/usr/include/gtk-4.0

The folder structure is as follows:

gtk-4.0
------->gdk
------->gsk
------->gtk
------->unix-print

Thus, when I want to include gtk.h for instance I need to write #include <gtk-4.0/gtk/gtk.h>

But an include statement such as this proves to be problematic, I first noticed this when my LSP raised an error such as In included file: 'gtk/css/gtkcss.h' file not found next to #include <gtk-4.0/gtk/gtk.h>

The file which's existence is denied is there, but because in the source file gtk.h it has been tried to access with the #include <gtk/css/gtkcss.h>statement without gtk-4.0/ at the start it's obsolete. This problem occurs everywhere in the codebase.

Being naive, I thought that moving the contents of gtk-4.0 to usr/include(I needed root access for that, which I think is a sign that that was not the optimal solution) would solve the problem. It did to some extent, but then it complained about not finding glib.h which again was in a parent folder called glib-2.0 not deterring from my irrational way of a solution, I then proceeded to move the contents of that folder as well to usr/include. Just as I thought that I had solved it, it started to complain about something else, at which point I got scared and reverted the possible damage inflicted on my include file with timeshift.

I have scoured the web in searches of an answer, but wasn't able to find anything of help. I would be grateful if someone happened to know the solution.

EDIT:

pkg-config --cflags --libs gtk4 after adding this to my gcc arguments, I can compile my project. I also added the outputs of pkg-config --cflags gtk4 to my include directories and now my LSP picks up on auto-complete, but this is no good solution in my opinion I should be able to access it just by gtk/gtk.h omitting the gkt-4.0/

Di0n
  • 65
  • 4
  • 2
    I think you have already solved your problem. The output of `pkg-config --cflags gtk4` contains the flag `-I/usr/include/gtk-4.0`. Which means that everything in `#include <>` will also get picked up from `/usr/include/gtk-4.0`. `#include ` should now be possible. – lambda-larry Jun 11 '23 at 23:00
  • Well, that is now possible yes, but I had to add the whole output of `pkg-config --cflags gtk4` to the include directories of my language server in order to avoid some other dependency conflicts, which shouldn't be necessary in my opinion I will try to apply a recursive search to `/usr/include/` maybe that will solve the problem. – Di0n Jun 12 '23 at 10:56
  • I just applied recursive search by adding `"/usr/include/**" , "/usr/lib/x86_64-linux-gnu/**"` which covers all the necessary includes and works I wonder if there's a way to edit system C_PATH to be recursive, that wouldn't require configuring the LSP – Di0n Jun 12 '23 at 11:02

0 Answers0