PDA

View Full Version : [ubuntu] [SOLVED] Glade/GTK very beginners question



anewguy
April 22nd, 2008, 05:38 AM
I have been following one of the online tutorials for using Glade and GTK. In the very first sample program (it only creates a window and destroys it when the box is clicked) it has the following lines:

/*
To compile, use this command (those are backticks, not single quotes):
gcc -Wall -g -o tutorial main.c `pkg-config --cflags --libs gtk+-2.0 libglade-2.0`
*/


As far as I can tell, I think I have GTK installed, but when I run the above gcc (changed to match my source name) I get the following:

dave@dave-desktop:~/cvsutil/src$ gcc -Wall -g -o cvsutil cvsutilgtk.c `pkg-config --cflags --libs gtk+-2.0 libglade-2.0`
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
Package libglade-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libglade-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libglade-2.0' found
cvsutilgtk.c:5:21: error: gtk/gtk.h: No such file or directory
cvsutilgtk.c:6:25: error: glade/glade.h: No such file or directory
cvsutilgtk.c: In function ‘main’:
cvsutilgtk.c:11: error: ‘GladeXML’ undeclared (first use in this function)
cvsutilgtk.c:11: error: (Each undeclared identifier is reported only once
cvsutilgtk.c:11: error: for each function it appears in.)
cvsutilgtk.c:11: error: ‘gxml’ undeclared (first use in this function)
cvsutilgtk.c:12: error: ‘GtkWidget’ undeclared (first use in this function)
cvsutilgtk.c:12: error: ‘window’ undeclared (first use in this function)
cvsutilgtk.c:14: warning: implicit declaration of function ‘gtk_init’
cvsutilgtk.c:16: warning: implicit declaration of function ‘glade_xml_new’
cvsutilgtk.c:16: error: ‘NULL’ undeclared (first use in this function)
cvsutilgtk.c:17: warning: implicit declaration of function ‘glade_xml_get_widget’
cvsutilgtk.c:18: warning: implicit declaration of function ‘glade_xml_signal_connect’
cvsutilgtk.c:19: warning: implicit declaration of function ‘G_CALLBACK’
cvsutilgtk.c:19: error: ‘gtk_main_quit’ undeclared (first use in this function)
cvsutilgtk.c:21: warning: implicit declaration of function ‘g_object_unref’
cvsutilgtk.c:21: warning: implicit declaration of function ‘G_OBJECT’
cvsutilgtk.c:23: warning: implicit declaration of function ‘gtk_widget_show’
cvsutilgtk.c:24: warning: implicit declaration of function ‘gtk_main’
dave@dave-desktop:~/cvsutil/src$

I know after it not finding the gtk package that everything else is a result of that.

What should a beginner like me do?

Thanks! :)

EDIT: Forgot to mention that glade and gtk seem to be installed in /usr/lib if that helps any.

tonyr1988
April 22nd, 2008, 06:09 AM
I haven't messed with GTK much, but I believe you'll need the libgtk2.0-dev package in Synaptic, or:


sudo apt-get install libgtk2.0-dev

anewguy
April 22nd, 2008, 07:59 AM
Tried what you suggested - it installed some stuff, but the compile still fails just the same.

I tried changing the gcc line by removing the PKG_CONFIG_PATH and just putting -l in front of each library name as I have done in the past:

gcc -Wall -g -o cvsutil cvsutilgtk.c -lgtk+-2.0 -llibglade-2.0


The results are slightly changed, but I still can't figure out what is wrong (like WHERE is looking for the /glade and /gtk directories??):

dave@dave-desktop:~/cvsutil/src$ gcc -Wall -g -o cvsutil cvsutilgtk.c -lgtk+-2.0 -llibglade-2.0
cvsutilgtk.c:5:21: error: gtk/gtk.h: No such file or directory
cvsutilgtk.c:6:25: error: glade/glade.h: No such file or directory

Followed of course by a lot of "not declared" type errors.

I'm really quite confused here. Any help would be appreciated!! :(

anewguy
April 23rd, 2008, 12:23 AM
Fixed those errors by uninstalling glade and installing glade-gnome packages.

Thanks for the help! :)