You are not logged in.

#1 2015-06-15 02:47:40

rws
Member
Registered: 2015-06-15
Posts: 2

[SOLVED] gtk/gtk.h: No such file or directory

I am new to c. I am trying to compile the example code at [1] with `gcc
example.c`, where example.c is that code.

I get:

In file included from /usr/include/girara/session.h:8:0,
                 from /usr/include/girara/girara.h:7,
                 from example.c:4:
/usr/include/girara/callbacks.h:7:21: fatal error: gtk/gtk.h: No such file or directory
compilation terminated.

I have the official girara, gtk2, and gtk3 packages installed. Similar: [2].
`gcc -lgtk-3 example.c` gives the same error. It's my understanding that the
official packages themselves also have the header files with them?

Output of `pacman -Ql gtk3` is [3]. As you can see, I have
/usr/include/gtk-3.0/gtk/gtk.h (line 189).

Output of `pkg-config --cflags --libs gtk+-3.0` is:

-pthread -I/usr/include/gtk-3.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/at-spi-2.0 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/gtk-3.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/libdrm -I/usr/include/libpng16 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libpng16 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -lgtk-3 -lgdk-3 -lpangocairo-1.0 -lpango-1.0 -latk-1.0 -lcairo-gobject -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lgobject-2.0 -lglib-2.0 

I'm clearly missing something or missing some package but can't figure out
what. I think this might be the way my system is set up, hence posting here.

[1]: https://pwmt.org/projects/girara/code/
[2]: https://bbs.archlinux.org/viewtopic.php?id=178472
[3]: http://pastebin.com/VyBYN1XP

Last edited by rws (2015-06-15 06:38:26)

Offline

#2 2015-06-15 06:20:07

mauritiusdadd
Member
From: Benevento, Italy
Registered: 2013-10-27
Posts: 776

Re: [SOLVED] gtk/gtk.h: No such file or directory

Hi rws and welcome to the forums big_smile

You have to tell to gcc where the missing hearer is, using the option -I/usr/include/gtk-3.0 (see https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html). Also pkg-config is not called automatically by gcc so if you want to use it instead of passing the options manually, you must use the command

gcc example.c $(pkg-config --cflags --libs gtk+-3.0 girara-gtk3)

If you are new to C, I suggest you to start with a tutorial like Learn C The Hard Way.
And you may want to read the also gcc documentation.

Last edited by mauritiusdadd (2015-06-15 06:21:36)


About me - github

-- When you have eliminated the impossible, whatever remains, however improbable, must be the truth -- Spock | Sherlock Holmes

Offline

#3 2015-06-15 06:37:50

rws
Member
Registered: 2015-06-15
Posts: 2

Re: [SOLVED] gtk/gtk.h: No such file or directory

Brilliant. It worked with using pkg-config as you said. And thanks for the link!

Offline

Board footer

Powered by FluxBB