0

I know this question has been answered several times, I have tried each of them but still could not find the exact solution. I am starting to learn GTK + 3.0 with Glade User Interface. i know Glade will generate XML for the design and the same XML can be used in our c/cpp program. But to execute the program, one must have all the libraries installed or path must be set to the libraries in IDE's. I am using Anjuta IDE for developing this program whenever i tried to build the program I get the following error.

gtk/gtk.h: No such file or directory

enter image description here

Program code

#include <gtk/gtk.h>!
#include <glade/glade.h>

void
ok_button_clicked (GtkWidget *widget, gpointer user_data)
{
  printf ("Thanks for trying out my program.\n");
  gtk_main_quit ();
}

int main (int argc, char *argv[])
{
  GladeXML  *main_window;
  GtkWidget *widget;

  gtk_init (&argc, &argv);

  /* load the interface */
  main_window = glade_xml_new ("example-1.glade", NULL, NULL);

  /* connect the signals in the interface */

  /* Have the ok button call the ok_button_clicked callback */
  widget = glade_xml_get_widget (main_window, "OKButton");
  g_signal_connect (G_OBJECT (widget), "clicked",
                    G_CALLBACK (ok_button_clicked),
                    NULL);

  /* Have the delete event (window close) end the program */
  widget = glade_xml_get_widget (main_window, "MainWindow");
  g_signal_connect (G_OBJECT (widget), "delete_event",
                    G_CALLBACK (gtk_main_quit), NULL);

  /* start the event loop */
  gtk_main ();

  return 0;
}

Whenever I try to add Lib or External Lib, I am not able to add gtk/gtk.h file, The same file is already there in /usr/include/gtk-3.0/gtk/gtk.h and when I try to copy the same in libanjuta the same code still giving the same error, Any help will be highly appreciated friends, I am struggling lot to execute the program ..

Thanks Amul Bhatia

Amul Bhatia
  • 398
  • 2
  • 6
  • 14

1 Answers1

1

If you just want to compile it and run other than making a makefile

save this file in the link beside your foobar.c file as example-1.glade

https://github.com/interval1066/XFC/blob/master/examples/glade/example-1/example-1.glade

and open terminal and switch to directory containing foobar.c and example-1.glade and issue this line

 gcc -o foobar foobar.c `pkg-config --cflags --libs libglade-2.0`

and run the binary

 ./foobar

Or if you insist on compiling it with makefile, replace your makefile with this one

 ## Created by Anjuta

 CC = gcc
 CFLAGS = -g -Wall
 OBJECTS = foobar.o
 INCFLAGS = 
 LDFLAGS = -Wl,-rpath,/usr/local/lib
 LIBS =$(shell pkg-config gtk+-2.0 libglade-2.0 --libs)

 GTKFLAGS=-export-dynamic `pkg-config --cflags --libs libglade-2.0 `
 all: foobar

 foobar: $(OBJECTS)
$(CC) -o foobar $(OBJECTS) $(LDFLAGS) $(LIBS)

 .SUFFIXES:
 .SUFFIXES: .c .cc .C .cpp .o

 .c.o :
    $(CC) -o $@ -c $(CFLAGS) $< $(INCFLAGS) $(GTKFLAGS)

 count:
    wc *.c *.cc *.C *.cpp *.h *.hpp

 clean:
    rm -f *.o

 .PHONY: all
 .PHONY: count
 .PHONY: clean

I tested above instructions in my system, it works.

kenn
  • 5,232