You are not logged in.
Hello! I have read about 20 pages of people reporting this problem... Most of the time the questions weren't answered or the problem was due to a typo made in the Makefile of the associated file. It has never been so difficult to use a library before, I have done it successfully multiple times.
In the first line of my main.cpp I include the library using #include <gtk/gtk.h>
I get this error message: "fatal error: gtk/gtk.h: no such file or directory.
While running the pkg-config command I see that I have everything installed: gtk4, gtk+-3.0 (the one that I am using), gtk+-2.0 and many more
In my Makefile I include gtk+3 as follows:
LD_FLAGS = `pkg-config --libs gtk+-3.0 `
The Makefile structures works 100% on every library I have tried except this one. I know that this is the correnc way of using the library in my program as this is the name of it in pkg-config.
When I do #include <gtk-3.0/gtk/gtk.h> The program works beyond the first line but then gtk.h itself can't include anything that it requires, it can't find the other files it lists. And of course gtk-3.0/ has the appropriate files in it although many are missing... I have tried to unistall the library and reinstall it but the problem still persists.
Thanks!
Offline
see `pkg-config --cflags gtk+-3.0`. That needs to be included in CFLAGS.
Last edited by Scimmia (2023-07-31 05:33:35)
Offline
Thanks! It seems to find the file even if I do #include <gtk/gtk.h>. Although the file still can't include anything by itself.
It gives this error which is the first include line of gtk.h. This error makes sense because there is no such file in the directory of gtk...
fatal error: gtk/css/gtkcss.h: No such file or directory
35 | #include <gtk/css/gtkcss.h>
EDIT: This time I reinstalled the gtk library again but from the source code of gnomes gitlab and found out that I was missing 5 folders. Still it has many libraries missing. Sorry for making this questions, I will first fix the missing libraries and then tell you whether or not the problem is still present
Last edited by pioyi (2023-07-31 05:59:34)
Offline
I was unable to fix the problem even though I downloaded the files from source again... I just included gtk4 and now I will be working with that version. I am sorry for taking your time! I am too new to this to completely understand why it wasn't working but for now I am going to work with that!
Offline
I'd gather the problem is / was just in your Makefile and pkg-config use as alluded to above. With this, note that you are using LD_FLAGS in your first post when you should be using LD_LIBS. In many common use cases this "error" would be benign as it would work fine by coincidence, but it's a bad habit that would likely lead to trouble in the future that may then be hard to understand. So practice proper habits now and use LD_LIBS for libs.
In any case, if you have a solution, please mark the thread as SOLVED. If you are not yet satisfied, post your complete Makefile (in code tags).
EDIT: oops, both LD_FLAGS and LD_LIBS are wrong, the relevant variables are LDLIBS and LDFLAGS! I've left the original text above for context, but this is even more odd. I don't believe LD_FLAGS is used by any implicit rules, so I gather you are just using it as your own variable and naming it very closely but not quite the same as a implicit rule variable: that's confusing as hell, don't do that! This also suggests that you are hardcoding your own build rules which is typically not a great idea; while there are certainly exceptions, the level of this question makes me doubt that this would be an exception.
Last edited by Trilby (2023-07-31 14:34:30)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Online