How to compile GTK +?! I read the manuals and there are connected "options" but something is missing.
pkg-config --cflags --libs gtk+-3.0
Error
/home/hays/program/test/GTK+/main.c:3:43: error: unknown type name 'GtkEventAny' static gint delete_event_cb(GtkWidget *w, GtkEventAny *e, ^ /home/hays/program/test/GTK+/main.c: In function 'main': /home/hays/program/test/GTK+/main.c:21:24: error: 'GTK_WINDOW' undeclared (first use in this function) gtk_window_set_title(GTK_WINDOW), "Hello"); ^ /home/hays/program/test/GTK+/main.c:21:24: note: each undeclared identifier is reported only once for each function it appears in /home/hays/program/test/GTK+/main.c:21:3: error: too few arguments to function 'gtk_window_set_title' gtk_window_set_title(GTK_WINDOW), "Hello"); ^ In file included from /usr/include/gtk-3.0/gtk/gtkdialog.h:33:0, from /usr/include/gtk-3.0/gtk/gtkaboutdialog.h:30, from /usr/include/gtk-3.0/gtk/gtk.h:31, from /home/hays/program/test/GTK+/main.c:1: /usr/include/gtk-3.0/gtk/gtkwindow.h:147:12: note: declared here void gtk_window_set_title (GtkWindow *window, ^ /home/hays/program/test/GTK+/main.c:21:35: warning: left-hand operand of comma expression has no effect [-Wunused-value] gtk_window_set_title(GTK_WINDOW), "Hello"); ^ /home/hays/program/test/GTK+/main.c:21:3: warning: statement with no effect [-Wunused-value] gtk_window_set_title(GTK_WINDOW), "Hello"); ^ /home/hays/program/test/GTK+/main.c:21:44: error: expected ';' before ')' token gtk_window_set_title(GTK_WINDOW), "Hello"); ^ /home/hays/program/test/GTK+/main.c:21:44: error: expected statement before ')' token /home/hays/program/test/GTK+/main.c:24:3: warning: implicit declaration of function 'gtk_signal_connect' [-Wimplicit-function-declaration] gtk_signal_connect(GTK_OBJECT(window), "delete_event", ^ /home/hays/program/test/GTK+/main.c:24:3: warning: implicit declaration of function 'GTK_OBJECT' [-Wimplicit-function-declaration] /home/hays/program/test/GTK+/main.c:25:22: warning: implicit declaration of function 'GTK_SIGNAL_FUNC' [-Wimplicit-function-declaration] GTK_SIGNAL_FUNC(delete_event_cb), NULL); ^ /home/hays/program/test/GTK+/main.c:25:38: error: 'delete_event_cb' undeclared (first use in this function) GTK_SIGNAL_FUNC(delete_event_cb), NULL); ^ /home/hays/program/test/GTK+/main.c: In function 'button_click_cb': /home/hays/program/test/GTK+/main.c:49:3: warning: implicit declaration of function 'gtk_label_get' [-Wimplicit-function-declaration] gtk_label_get(GTK_LABEL(label), &text); ^ /home/hays/program/test/GTK+/main.c:51:3: warning: implicit declaration of function 'g_str_reverse' [-Wimplicit-function-declaration] g_str_reverse(tmp); ^ /home/hays/program/test/GTK+/main.c:52:3: warning: implicit declaration of function 'gtl_label_set_text' [-Wimplicit-function-declaration] gtl_label_set_text(GTK_LABEL(label), tmp); ^ /home/hays/program/test/GTK+/main.c: At top level: /home/hays/program/test/GTK+/main.c:35:13: warning: 'delete_event_cb' defined but not used [-Wunused-function] static gint delete_event_cb(GtkWidget *window, GdkEventAny *e, Code
#include <gtk/gtk.h> static gint delete_event_cb(GtkWidget *w, GtkEventAny *e, gpointer data); static void button_click_cb(GtkWidget *w, gpointer data); int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *button; GtkWidget *label; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); button = gtk_button_new(); label = gtk_label_new("Hello, World!"); gtk_container_add(GTK_CONTAINER(button), label); gtk_container_add(GTK_CONTAINER(window), button); gtk_window_set_title(GTK_WINDOW, "Hello"); gtk_container_set_border_width(GTK_CONTAINER(button), 10); gtk_signal_connect(GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC(delete_event_cb), NULL); gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(button_click_cb), label); gtk_widget_show_all(window); gtk_main(); return 0; } static gint delete_event_cb(GtkWidget *window, GdkEventAny *e, gpointer data) { gtk_main_quit(); return FALSE; } static void button_click_cb(GtkWidget *w, gpointer data) { GtkWidget *label; gchar *text; gchar *tmp; label = GTK_WIDGET(data); gtk_label_get(GTK_LABEL(label), &text); tmp = g_strdup(text); g_str_reverse(tmp); gtl_label_set_text(GTK_LABEL(label), tmp); g_free(tmp); }