LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   error: gtk/gtk.h: No such file or directory (https://www.linuxquestions.org/questions/programming-9/error-gtk-gtk-h-no-such-file-or-directory-795475/)

Aquarius_Girl 03-15-2010 04:19 AM

error: gtk/gtk.h: No such file or directory
 
Below is my C code:
Code:

#include <gtk/gtk.h>
int main ()
{
    return 0;
}

Below is the compilation output of this code !
Code:

anisha@linux-p0mg:~> gcc -I/usr/include/gtk-2.0/gtk/ j.c
j.c:1:21: error: gtk/gtk.h: No such file or directory

The most relevant packages I have installed are listed below:
Quote:

gtk2
gtk2-devel
gtkmm2
gtkmm2-devel
wxGtk
wxGtk-devel
Have I missed something out ?

Kindly guide !

Sayan Acharjee 03-15-2010 04:27 AM

May be you need to install gtk+ and libgtk+, I'm not sure though.

Aquarius_Girl 03-15-2010 06:36 AM

Quote:

Originally Posted by sayan_acharjee
May be you need to install gtk+ and libgtk+, I'm not sure though.

That didn't help, BUT THANKS FOR BOTHERING TO REPLY,

I managed to solve the problem myself:
Here's my solution:

I had compiled it wrongly first of all !

Correct way:
Code:

gcc -I/usr/include/gtk-2.0/ j.c
This resulted in many other errors like unable to find
glib.h, gtk.h, glib.h, glibconfig.h, pango.h, gdkconfig.h, atkobject.h, pkgconfig.h


Then I did the following:
Code:

export CPATH=$CPATH:/usr/include/gtk-2.0
export CPATH=$CPATH:/usr/include/glib-2.0/
export CPATH=$CPATH:/usr/lib/glib-2.0/include/
export CPATH=$CPATH:/usr/include/pango-1.0/
export CPATH=$CPATH:/usr/lib/gtk-2.0/include/
export CPATH=$CPATH:/usr/include/atk-1.0/

and then installed gdk-pixbuf and gdk-pixbuf-devel packages !

and now I can compile it simply like this: gcc j.c

Sayan Acharjee 03-15-2010 07:25 AM

Thanks for sharing the solution :)

Aquarius_Girl 03-15-2010 07:28 AM

Most welcome :D

leibnix 03-03-2011 09:29 AM

I'm also starting out with gtk now. I struggled a lot with compiling hello-world until I found the 'GNOME Documentation Library'.

Basically, the pkg-config utility can produce all (or most of) the include options you need for compiling. try typing:

Code:

pkg-config --libs gtk+-2.0
To compile hello.c with gtk2.0, just type:

Code:

gcc `pkg-config --cflags --libs gtk+-2.0` hello.c -o hello
Note the fancy backticks. They work somewhat like quotes in lisp and expands the output from the pkg-config program into the your command.

I guess this means less cluttering of the environment, and you can easily change the 2.0 to 3.0 without rewriting all your scripts.

thanks,
tor

houqi 03-28-2011 04:17 AM

I met the same problom that you countered,but resolved it
 
Actually,it's simple to resole,though it confused me a whole day.
Noting,there is diference between " ' " and " ` "," ' " is single quotes,the other symbol shares the key with "~".
The correct symbol is last one that shared the key with "~".


All times are GMT -5. The time now is 10:37 AM.