LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 12-02-2006, 01:40 PM   #1
xlinuks
Member
 
Registered: Jan 2006
Location: White House
Distribution: Ubuntu 8.10
Posts: 39

Rep: Reputation: 15
GTK environment setup


Hi all, after some troubles I got to setup almost all the GTK devel packages and now I'm trying to compile a program from the "Beginning Linux Programming" book (3rd edition).
The problem is that the gcc compiler doesn't recognize the:
#include <gtk/gtk.h>
saying no such file or directory.

so when I'm hardcoding it like this:
#include "/usr/include/gtk-2.0/gtk/gtk.h"

the compiler issues a lot of unresolved headers like:
$ gcc gtk1.c -o gtk1 `pkg-config -cflags -libs gtk+-2.0`
-cflags: unknown option
In file included from gtk1.c:1:
/usr/include/gtk-2.0/gtk/gtk.h:31:21: error: gdk/gdk.h: No such file or directory
/usr/include/gtk-2.0/gtk/gtk.h:32:32: error: gtk/gtkaboutdialog.h: No such file or directory
/usr/include/gtk-2.0/gtk/gtk.h:33:31: error: gtk/gtkaccelgroup.h: No such file or directory

I think there should be some environment variable telling the compiler where to look for the header files. BUT it looks like although the pkg-config program is there - it doesn't work correctly since it complains "-cflags: unknown option".

Someone please tell me how to setup the compiler or my environment to get the code to compile, here's the code of the simple app:
#include "/usr/include/gtk-2.0/gtk/gtk.h"
//<gtk/gtk.h>
int main (int argc, char *argv[])
{
GtkWidget *window;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_show(window);
gtk_main ();
return 0;
}
 
Old 12-02-2006, 02:08 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
never ever ever ever use absolute filenames in include statements, absolutely daft idea. don't.

clearly you're not using the pkgconfig command correctly, as it's complaining about the optiosn you're running it with, try --cflags instead of -cflags.
 
Old 12-02-2006, 02:15 PM   #3
xlinuks
Member
 
Registered: Jan 2006
Location: White House
Distribution: Ubuntu 8.10
Posts: 39

Original Poster
Rep: Reputation: 15
OMG!!!!
THANK YOU SO MUCH!!!! it works!!
 
  


Reply



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
setup java environment sunhui Linux - Software 4 11-22-2006 03:57 AM
Looking for build environment setup recommendations hq4ever Programming 1 11-09-2006 09:19 AM
Posix programming environment setup jfitzger68 Programming 5 07-22-2005 01:12 PM
GTK environment configuration Womandrake Linux - General 5 04-30-2003 01:27 PM
How to setup environment variables?? devraj Linux - Newbie 2 12-17-2001 04:30 AM

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

All times are GMT -5. The time now is 11:41 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
Open Source Consulting | Domain Registration