compiling simple gtk app

Hey everyone

I’m new with linux coding and have been looking at several tutorials for gtk and glade.

Now every code example starts with the:

#include <gtk/gtk.h>

and the compile fails instantly as the file is not there. I installed all the packages in the category “programming” in yast soft. manager, just to be sure.

Do I need a different repo or is there something else different with opensuse??

Hi Marko
when you say you installed everything under the “Programming” category, did you mean the “Development” category in yast?
there should be a package “gtk-devel” under the development category that includes all the files you need. You can also do a search from yast for “gtk-devel”

Thanks to your hint, I managed to nudge forward. But it just seems to get harder. gtk-devel was installed and I looked at the installed files to locate gtk.h. I then tried to change the include path to ‘gtk-1.2/gtk’ where the gtk.h appears to be located but now everything else seems to point at the folder ‘gtk’

This is the command line for the compile:
gcc -Wall -g -o tutorial main.c ‘pkg-config --cflags --libs gtk±2.0’ -export-dynamic

And here’s the output:
gcc: pkg-config --cflags --libs gtk±2.0: No such file or directory
In file included from main.c:1:
/usr/include/gtk-1.2/gtk/gtk.h:31:21: error: gdk/gdk.h: No such file or directory
/usr/include/gtk-1.2/gtk/gtk.h:32:31: error: gtk/gtkaccelgroup.h: No such file or directory
/usr/include/gtk-1.2/gtk/gtk.h:33:31: error: gtk/gtkaccellabel.h: No such file or directory
/usr/include/gtk-1.2/gtk/gtk.h:34:31: error: gtk/gtkadjustment.h: No such file or directory
/usr/include/gtk-1.2/gtk/gtk.h:35:30: error: gtk/gtkalignment.h: No such file or directory
/usr/include/gtk-1.2/gtk/gtk.h:36:24: error: gtk/gtkarg.h: No such file or directory
… the list goes on …
/usr/include/gtk-1.2/gtk/gtk.h:135:31: error: gtk/gtkvseparator.h: No such file or directory
/usr/include/gtk-1.2/gtk/gtk.h:136:27: error: gtk/gtkwidget.h: No such file or directory
/usr/include/gtk-1.2/gtk/gtk.h:137:27: error: gtk/gtkwindow.h: No such file or directory
main.c:3: error: expected ‘)’ before ‘
’ token
main.c: In function ‘main’:
main.c:10: error: ‘GtkBuilder’ undeclared (first use in this function)
main.c:10: error: (Each undeclared identifier is reported only once
main.c:10: error: for each function it appears in.)
main.c:10: error: ‘builder’ undeclared (first use in this function)
main.c:11: error: ‘GtkWidget’ undeclared (first use in this function)
main.c:11: error: ‘window’ undeclared (first use in this function)
main.c:13: warning: implicit declaration of function ‘gtk_init’
main.c:15: warning: implicit declaration of function ‘gtk_builder_new’
main.c:16: warning: implicit declaration of function ‘gtk_builder_add_from_file’
main.c:16: error: ‘NULL’ undeclared (first use in this function)
main.c:17: warning: implicit declaration of function ‘GTK_WIDGET’
main.c:17: error: ‘gtk_builder_get’ undeclared (first use in this function)
main.c:17: error: expected ‘)’ before ‘object’
main.c:18: warning: implicit declaration of function ‘gtk_buider_connect_signals’
main.c:20: warning: implicit declaration of function ‘g_object_unref’
main.c:20: warning: implicit declaration of function ‘G_OBJECT’
main.c:22: warning: implicit declaration of function ‘gtk_widget_show’
main.c:23: warning: implicit declaration of function ‘gtk_main’*

I appear to be missing one ‘pkg-config’ as well.

try installing the following packages:

  • gtkextra2-devel*]libgtkextra-x11-2_0-1*]gtkglext*]gtkglext-devel

im guessing, but I hope it helps!