Здравствуйте, руководствовался статьей "Программирование для GTK+" (
http://symmetrica.net/uploads/gtk/lesson1.htm)
Установил пакеты в синаптике со всеми зависимостями:
gtk+-devel*
atk-devel*
pango-devel*
libgnome-devel
glade.
kirill@work:~$ pkg-config --libs gtk+-2.0
-pthread -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lpangoft2-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lcairo -lgio-2.0 -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0
программа из статьи helloworld.c :
#include <gtk/gtk.h>
static void button_clicked(GtkWidget
* widget, gpointer data)
{
g_print("Button was clicked!\n");
}
static gboolean delete_event(GtkWidget * widget, GdkEvent * event, gpointer data)
{
g_print("Delete event occurred\n");
return FALSE;
}
static void destroy(GtkWidget * widget, gpointer data)
{
g_print("Destroy signal was sent\n");
gtk_main_quit();
}
int main(int argc, char ** argv)
{
GtkWidget * window;
GtkWidget * button;
const gchar * title = "Hello World!";
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(window), title);
gtk_container_set_border_width(GTK_CONTAINER(window), 10);
g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(delete_event), NULL);
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(destroy), NULL);
button = gtk_button_new_with_label("Quit");
g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(button_clicked), NULL);
g_signal_connect_swapped(G_OBJECT(button), "clicked", G_CALLBACK(gtk_widget_destroy), G_OBJECT(window));
gtk_container_add(GTK_CONTAINER(window), button);
gtk_widget_show(button);
gtk_widget_show(window);
gtk_main();
return 0;
}
gcc -Wall helloworld.c -o helloworld `pkg-config
--cflags gtk+-2.0` `pkg-config --libs gtk+-2.0`
при компиляции выдаёт ошибки:
Must specify package names on the command line
--cflags: command not found
helloworld.c:7:21: error: gtk/gtk.h: Нет такого файла или каталога
helloworld.c:9: error: expected ‘)’ before ‘*’ token
helloworld.c:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘delete_event’
helloworld.c:20: error: expected ‘)’ before ‘*’ token
helloworld.c: In function ‘main’:
helloworld.c:28: error: ‘GtkWidget’ undeclared (first use in this function)
helloworld.c:28: error: (Each undeclared identifier is reported only once
helloworld.c:28: error: for each function it appears in.)
helloworld.c:28: error: ‘window’ undeclared (first use in this function)
helloworld.c:29: error: ‘button’ undeclared (first use in this function)
helloworld.c:30: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribuMust specify package names on the command line
--cflags: command not found
helloworld.c:7:21: error: gtk/gtk.h: Нет такого файла или каталога
helloworld.c:9: error: expected ‘)’ before ‘*’ token
helloworld.c:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘delete_event’
helloworld.c:20: error: expected ‘)’ before ‘*’ token
helloworld.c: In function ‘main’:
helloworld.c:28: error: ‘GtkWidget’ undeclared (first use in this function)
helloworld.c:28: error: (Each undeclared identifier is reported only once
helloworld.c:28: error: for each function it appears in.)
helloworld.c:28: error: ‘window’ undeclared (first use in this function)
helloworld.c:29: error: ‘button’ undeclared (first use in this function)
helloworld.c:30: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘*’ token
helloworld.c:30: error: ‘title’ undeclared (first use in this function)
helloworld.c:31: warning: implicit declaration of function ‘gtk_init’
helloworld.c:32: warning: implicit declaration of function ‘gtk_window_new’
helloworld.c:32: error: ‘GTK_WINDOW_TOPLEVEL’ undeclared (first use in this function)
helloworld.c:33: warning: implicit declaration of function ‘gtk_window_set_title’
helloworld.c:33: warning: implicit declaration of function ‘GTK_WINDOW’
helloworld.c:34: warning: implicit declaration of function ‘gtk_container_set_border_width’
helloworld.c:34: warning: implicit declaration of function ‘GTK_CONTAINER’
helloworld.c:35: warning: implicit declaration of function ‘g_signal_connect’
helloworld.c:35: warning: implicit declaration of function ‘G_OBJECT’
helloworld.c:35: warning: implicit declaration of function ‘G_CALLBACK’
helloworld.c:35: error: ‘delete_event’ undeclared (first use in this function)
helloworld.c:35: error: ‘NULL’ undeclared (first use in this function)
helloworld.c:36: error: ‘destroy’ undeclared (first use in this function)
helloworld.c:37: warning: implicit declaration of function ‘gtk_button_new_with_label’
helloworld.c:38: error: ‘button_clicked’ undeclared (first use in this function)
helloworld.c:39: warning: implicit declaration of function ‘g_signal_connect_swapped’
helloworld.c:39: error: ‘gtk_widget_destroy’ undeclared (first use in this function)
helloworld.c:40: warning: implicit declaration of function ‘gtk_container_add’
helloworld.c:41: warning: implicit declaration of function ‘gtk_widget_show’
helloworld.c:43: warning: implicit declaration of function ‘gtk_main’te__’ before ‘*’ token
helloworld.c:30: error: ‘title’ undeclared (first use in this function)
helloworld.c:31: warning: implicit declaration of function ‘gtk_init’
helloworld.c:32: warning: implicit declaration of function ‘gtk_window_new’
helloworld.c:32: error: ‘GTK_WINDOW_TOPLEVEL’ undeclared (first use in this function)
helloworld.c:33: warning: implicit declaration of function ‘gtk_window_set_title’
helloworld.c:33: warning: implicit declaration of function ‘GTK_WINDOW’
helloworld.c:34: warning: implicit declaration of function ‘gtk_container_set_border_width’
helloworld.c:34: warning: implicit declaration of function ‘GTK_CONTAINER’
helloworld.c:35: warning: implicit declaration of function ‘g_signal_connect’
helloworld.c:35: warning: implicit declaration of function ‘G_OBJECT’
helloworld.c:35: warning: implicit declaration of function ‘G_CALLBACK’
helloworld.c:35: error: ‘delete_event’ undeclared (first use in this function)
helloworld.c:35: error: ‘NULL’ undeclared (first use in this function)
helloworld.c:36: error: ‘destroy’ undeclared (first use in this function)
helloworld.c:37: warning: implicit declaration of function ‘gtk_button_new_with_label’
helloworld.c:38: error: ‘button_clicked’ undeclared (first use in this function)
helloworld.c:39: warning: implicit declaration of function ‘g_signal_connect_swapped’
helloworld.c:39: error: ‘gtk_widget_destroy’ undeclared (first use in this function)
helloworld.c:40: warning: implicit declaration of function ‘gtk_container_add’
helloworld.c:41: warning: implicit declaration of function ‘gtk_widget_show’
helloworld.c:43: warning: implicit declaration of function ‘gtk_main’
перепроверял наличие пакетов из списка все имеется:
https://forum.ubuntu.ru/index.php?topic=2269.0# X
# * Compile: libx11-dev
# * Runtime: libx11-6
# GlibMM
# * Compile: libglibmm-2.4-dev
# * Runtime: libglibmm-2.4-1c2a
# GTK+
# * Compile: libgtk2.0-dev gtk-doc-tools
# * Runtime: libgtk2.0-0
# GTKMM
# * Compile: libgtkmm-2.4-dev
# * Runtime: libgtkmm-2.4-1c2a
# Glade
# * Compile: libglade2-dev
# * Runtime: libglade2-0
# GladeMM
# * Compile: libglademm-2.4-dev
# * Runtime: libglademm-2.4-1c2a
# XML
# * Compile: libxml2-dev
# * Runtime: libxml2
# XML++
# * Compile: libxml++2.6-dev
# * Runtime: libxml++2.6c2a
# DBus
# * Compile: libdbus-1-dev libdbus-glib-1-dev
# * Runtime: libdbus-1-2 libdbus-glib-1-2
# Alsa
# * Compile: libasound2-dev
# HAL
# * Compile: libhal-dev libhal-storage-dev
# * Runtime: libhal1 libhal-storage1
# Gamin
# * Compile: libgamin-dev
# * Runtime: libgamin0
# Neon
# * Compile: libneon25-dev
# * Runtime: libneon25
# TagLib
# * Compile: libtagc0-dev
# * Runtime: libtagc0
# Startup-Notify
# * Compile: libstartup-notification0-dev
# * Runtime: libstartup-notification0
# Boost
# * Compile: libboost-dev libboost-filesystem-dev
# * Runtime: libboost-filesystem1.33.1
# MusicBrainz
# * Compile: libmusicbrainz4-dev
# * Runtime: libmusicbrainz4c2a
# GStreamer
# * Compile: libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev
# * Runtime: libgstreamer0.10-0 libgstreamer-plugins-base0.10-0
Как исправить?
Заранее благодарен.