PDA

View Full Version : cant find gtk headers


Woody1987
January 10th, 2009, 04:10 PM
My program cant find the gtk headers. I have #include <gtk/gtk.h> in my program and i compile with
gcc main.c -o main 'pkg-config --cflags --libs gtk-2.0'

but i keep getting

gcc: pkg-config --cflags --libs gtk-2.0: No such file or directory
main.c:2:21: error: gtk/gtk.h: No such file or directory

i do have build-essential and libgtk2.0-dev installed and /usr/include/gtk-2.0 does exist

This is really annoying as it works fine on my other computer.

WW
January 10th, 2009, 04:56 PM
My program cant find the gtk headers. I have #include <gtk/gtk.h> in my program and i compile with
gcc main.c -o main 'pkg-config --cflags --libs gtk-2.0'

but i keep getting

gcc: pkg-config --cflags --libs gtk-2.0: No such file or directory
main.c:2:21: error: gtk/gtk.h: No such file or directory

Change those single quotes (') around the pkg-config command to single back-quotes (`).

Woody1987
January 10th, 2009, 05:05 PM
Change those single quotes (') around the pkg-config command to single back-quotes (`).

Tried it, no difference. Thanks anyway.

WW
January 10th, 2009, 05:15 PM
Tried it, no difference. Thanks anyway.

Are you sure? The error that you showed in your first post is exactly the error that you will get if you put single quotes around the pkg-config command. The single back-quotes, on the other hand, tell the shell to run the pkg-config command and put its output in place of the command.

Compare the output of the two echo commands in the following:

$ cd /tmp
$ echo 'pwd'
pwd
$ echo `pwd`
/tmp
$

Note that in the second echo command, the shell replaces `pwd` with the output of pwd before running echo. This is how you are trying to use the pkg-config command in your gcc command.

Hmmm... are you using bash as your shell? I don't know if the back-quotes work the same in other shells.

Woody1987
January 10th, 2009, 05:19 PM
matthew@Picard:~$ cd /tmp
matthew@Picard:/tmp$ echo 'pwd'
pwd
matthew@Picard:/tmp$ echo `pwd`
/tmp
matthew@Picard:/tmp$

how do i check if im using bash?

WW
January 10th, 2009, 05:24 PM
matthew@Picard:~$ cd /tmp
matthew@Picard:/tmp$ echo 'pwd'
pwd
matthew@Picard:/tmp$ echo `pwd`
/tmp
matthew@Picard:/tmp$

how do i check if im using bash?

The test you just ran makes it moot--whatever you are using (probably bash) handles the back-quotes.

Given that, I don't see how changing the single quotes to back-quotes can make "no difference" in your gcc command. Can you show the output that you get with this command (run in the same directory where your code is):

gcc main.c -o main `pkg-config --cflags --libs gtk-2.0`

Woody1987
January 10th, 2009, 05:27 PM
Package gtk-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk-2.0' found


I didnt notice it before, there is a difference. Sorry for wasting your time, but how do i fix this?

WW
January 10th, 2009, 05:35 PM
Package gtk-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gtk-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gtk-2.0' found


I didnt notice it before, there is a difference. Sorry for wasting your time,

No worries. :)

but how do i fix this?
The pkg-config name is actually gtk+-2.0 (go figure).

I found this by looking for the corresponding file with the .pc extension in the package's list of files (http://packages.ubuntu.com/intrepid/i386/libgtk2.0-dev/filelist) at packages.ubuntu.com. You could also look in /usr/lib/pkgconfig, or you can see the names of all the packages with the command pkg-config --list-all.

Woody1987
January 10th, 2009, 05:42 PM
im still not entirely sure what to do, could you explain a little further?

WW
January 10th, 2009, 05:48 PM
Try changing gtk-2.0 to gtk+-2.0 in your gcc command:

gcc main.c -o main `pkg-config --cflags --libs gtk+-2.0`

Woody1987
January 10th, 2009, 05:50 PM
YAY, thankyou so much