LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 02-01-2007, 10:13 PM   #1
ufmale
Member
 
Registered: Feb 2007
Posts: 386

Rep: Reputation: 30
compling gtk app problem


Can anyone help? This seems to be simple, but I don't know how to get it work. I am trying to compile a simple gtk app. I installed the gtk package, but still did not fix.

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

Here is how i compile the code,

$ gcc ghelloworld.c -o ghello 'pkg-config --cflags --libs gtk+-2.0'
gcc: pkg-config --cflags --libs gtk+-2.0: No such file or directory
ghelloworld.c:1:21: gtk/gtk.h: No such file or directory
ghelloworld.c: In function `main':
ghelloworld.c:6: error: `GtkWidget' undeclared (first use in this function)


The path looks correct..as i checked with following cmd,
$ echo $PKG_CONFIG_PATH
/usr/lib/pkgconfig/

$ pwd
/usr/include/gtk-2.0/gtk
$ ls gtk+*
gtk+-2.0.pc gtk+-x11-2.0.pc

The header file gtk.h is also at where it should be <gtk/gtk.h>
$ pwd
/usr/include/gtk-2.0/gtk
$ ls -l gtk.h
-rw-r--r-- 1 root root 5675 Sep 30 2005 gtk.h

I also check to make sure that the pkg-config work,
$ pkg-config --cflags --libs gtk+-2.0
-DXTHREADS -D_REENTRANT -DXUSE_MTSAFE_API -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/X11R6/include -I/usr/include/atk-1.0 -I/usr/include/pango-1.0 -I/usr/include/freetype2 -I/usr/include/freetype2/config -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -Wl,--export-dynamic -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangoxft-1.0 -lpangox-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0
 
Old 02-02-2007, 01:48 AM   #2
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
You need to use backticks instead of single quotes around the command:
gcc ghelloworld.c -o ghello `pkg-config --cflags --libs gtk+-2.0`
 
Old 02-02-2007, 08:19 AM   #3
ufmale
Member
 
Registered: Feb 2007
Posts: 386

Original Poster
Rep: Reputation: 30
that works. Thanks..
 
  


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
problem compling 2.6 tanalam Red Hat 16 07-10-2006 08:06 AM
'dialog' app for GTK+2.0 General Programming 6 04-23-2006 01:10 PM
XID in Gtk APP pulsez Programming 1 07-13-2005 06:12 PM
gtk app problem emg Linux - Software 3 04-30-2005 01:22 PM
probs compling gtk+-2.2.4 stabu Linux - Newbie 2 03-27-2004 06:20 AM

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

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