LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-07-2011, 11:52 PM   #1
rachel_s
LQ Newbie
 
Registered: Jun 2010
Posts: 15

Rep: Reputation: 1
GTK Programming - gtk disappears?


Hello,

I am a beginning programmer, trying to learn C and GTK. I started a tutorial and made it through the first two lessons, then on the third received a curious error:

Code:
fatal error: gtk/gtk.h: No such file or directory compilation terminated.
This is strange because the gtk/gtk.h pre-processor directive was clearly available for the first two programs; they compiled and ran just fine.

Thanks for any help with this.
 
Old 10-08-2011, 06:43 AM   #2
Doc CPU
Senior Member
 
Registered: Jun 2011
Location: Stuttgart, Germany
Distribution: Mint, Debian, Gentoo, Win 2k/XP
Posts: 1,099

Rep: Reputation: 343Reputation: 343Reputation: 343Reputation: 343
Hi there,

Quote:
Originally Posted by rachel_s View Post
Code:
fatal error: gtk/gtk.h: No such file or directory compilation terminated.
This is strange because the gtk/gtk.h pre-processor directive was clearly available for the first two programs; they compiled and ran just fine.
have a look at the C/C++ source files, especially the #include directive referencing the gtk.h header file. Is the header file name enclosed in quotation marks or brackets?
#include "gtk/gtk.h" starts searching from the directory that contains the C source file
#include <gtk/gtk.h> starts searching from the compiler's default or configured include directory

Right now, that's all I can think of as a reason.

[X] Doc CPU
 
Old 10-08-2011, 01:09 PM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,397
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Also, compare the compiler commandline arguments. If you are using make to build the program, the arguments may be embedded in the Makefile. Look especially for the '-I' (uppercase 'eye') argument, possibly embedded in something like ${CFLAGS}.

--- rod.
 
Old 10-09-2011, 01:25 AM   #4
rachel_s
LQ Newbie
 
Registered: Jun 2010
Posts: 15

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by Doc CPU View Post
Hi there,



have a look at the C/C++ source files, especially the #include directive referencing the gtk.h header file. Is the header file name enclosed in quotation marks or brackets?
#include "gtk/gtk.h" starts searching from the directory that contains the C source file
#include <gtk/gtk.h> starts searching from the compiler's default or configured include directory

Right now, that's all I can think of as a reason.

[X] Doc CPU
I'm using the correct delimiters:

Code:
#include <gtk/gtk.h>
Quote:
Originally Posted by theNbomr View Post
Also, compare the compiler commandline arguments. If you are using make to build the program, the arguments may be embedded in the Makefile. Look especially for the '-I' (uppercase 'eye') argument, possibly embedded in something like ${CFLAGS}.

--- rod.
I'm using

Code:
gcc codename.c -o programname
So I think I'm safe in this regard.

Thanks to both of you for your help. This problem seems quite perplexing; I hope I don't have to backup and do a re-install.

I at least wish I knew what I did to make the headers "disappear" so I don't pull that one again.
 
Old 10-09-2011, 01:34 AM   #5
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Quote:
Originally Posted by rachel_s View Post
Code:
gcc codename.c -o programname
You're not telling gcc where to find the headers, or to link the relevant libraries. The tutorial tells you how to specify the correct flags; you use pkg-config: http://developer.gnome.org/gtk-tutor...able/x111.html.
 
1 members found this post helpful.
Old 10-09-2011, 11:01 AM   #6
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,397
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
If the aforementioned tutorial is online, please post a link to it. If you are too new here to post links, send me a private LQ message with the link, and I'll post it if it works.
--- rod.
 
Old 10-09-2011, 11:11 PM   #7
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
For GTK+ you generally use `pkg-config --cflags gtk+-2.0` in the gcc call, in addition to your own options. Similarly, you'd use `pkg-config --libs gtk+-2.0` to get linker flags. Keep in mind that both provide flags corresponding to the configuration of your GTK+ installation; therefore, code the `...` into your makefile, not the output of the respective commands. So something like this, if you compile and link at the same time:
Code:
gcc `pkg-config --cflags gtk+-2.0` codename.c -o programname `pkg-config --libs gtk+-2.0`
Kevin Barry

Last edited by ta0kira; 10-09-2011 at 11:15 PM.
 
Old 10-10-2011, 11:06 PM   #8
rachel_s
LQ Newbie
 
Registered: Jun 2010
Posts: 15

Original Poster
Rep: Reputation: 1
Red face

Quote:
Originally Posted by Nylex View Post
You're not telling gcc where to find the headers, or to link the relevant libraries. The tutorial tells you how to specify the correct flags; you use pkg-config: http://developer.gnome.org/gtk-tutor...able/x111.html.
Quote:
Originally Posted by ta0kira View Post
For GTK+ you generally use `pkg-config --cflags gtk+-2.0` in the gcc call, in addition to your own options. Similarly, you'd use `pkg-config --libs gtk+-2.0` to get linker flags. Keep in mind that both provide flags corresponding to the configuration of your GTK+ installation; therefore, code the `...` into your makefile, not the output of the respective commands. So something like this, if you compile and link at the same time:
Code:
gcc `pkg-config --cflags gtk+-2.0` codename.c -o programname `pkg-config --libs gtk+-2.0`
Kevin Barry
Nylex and ta0kira: Thank you, this was it! Bit embarrassed...
 
Old 10-11-2011, 12:41 AM   #9
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
No problem. I did think it was slightly strange, though, as you said you'd been able to build other GTK+ programs without any trouble.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Inhibit GTK verbose messages when running GTK/Gnome applications from terminal d1s4st3r Linux - Software 1 11-10-2009 10:33 PM
Freerock uninstall stole GTK looking for up-to-date pango, atk, gtk, glib and xft tgz Oholiab Slackware 8 09-18-2005 11:57 AM
GTK source install doesn't give gtk-config Feebles Linux - Software 4 06-15-2005 12:51 PM
cant find gtk-config file or gtk-devel to install happychappy Linux - Software 2 02-16-2005 12:46 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:02 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration