Gtk.h: file not found

I have already searched google about 10 times trying to get an answer but, when I write a plain .txt file called “my_program.cpp” with the first line as #include <gtk/gtk.h> no matter what I do it can’t find gtk.h… I’ve tried adding environment variables, installing additional applications, and looking to find that the file is in fact in my includes folder!

I have tried with intel’s DPC++ and GCC but I have no luck, help…

Did you try passing the relevant cflags?

You may want to look at

Ive spent the last 2 hours searching google and stack overflow for a way to get the pkg-config parameter to work, no luck. does anyone know what i’m doing wrong??

The documentation seems pretty clear, to me:

You can compile the program above with GCC using:

gcc -o hello-world-gtk hello-world-gtk.c `pkg-config --cflags --libs gtk4`

The very same page also links to the reference page which explains how to compile any code using GTK.

Unfortunately you’ve not told us enough about what you’ve tried and how it failed for us to know what your doing wrong

well i’ve tried the --cflags --libs gtk4 thing (as written in the documentation), I am now trying to do all of the steps I took on ubuntu mate 22.04, on ubuntu 21.10 to see if that has any better outcomes…

in fact i’ve spent multiple hours entering pkg-config --cflags --libs gtk4

Could you copy and paste the exact command you’re using, along with all the output from the command, and post it here? That will help to diagnose the problem.

You need to install the development packages for GTK4, otherwise you won’t be able to build C/C++ code using GTK4.

You should also paste the commands you’re using, and the output, otherwise nobody will be able to help you.

FInally after 3 days i’ve got it to work, I had to use the ` ~~~~ quote above the tab key instead of using the single quote next to the return key! all of the manually barely mention doing that

It uses ` not ’ in every example?

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