GTK+界面设计

GTK+界面设计



先看一段例程:
——————————————————————————————
#include int main(int argc, char *argv[]){ GtkWidget *window; /* Initialize GTK+ and all of its supporting libraries.*/ gtk_init(&argc, &argv); /* Create a new window, give it a title and display it to the user. */ window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "Hello GTK"); gtk_widget_show(window); /* Hand control over to the main loop. */ gtk_main(); return 0; }
——————————————————————————————
可保存为try.c

编译过程:
1)命令行下
输入:
pkg-config --cflags gtk+-2.0
得到:
-mms-bitfields -Ic:/gtk/include/gtk-2.0 -Ic:/gtk/lib/gtk-2.0/include -Ic:/gtk/include/atk-1.0 -Ic:/gtk/include/cairo -Ic:/gtk/include/pango-1.0 -Ic:/gtk/include/glib-2.0 -Ic:/gtk/lib/glib-2.0/include -Ic:/gtk/include/libpng12

输入:
pkg-config --libs gtk+-2.0
得到:
-Lc:/gtk/lib -lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 -lgio-2.0 -lgdk_pixbuf-2.0 -lpangowin32-1.0 -lgdi32 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lintl

这两段都是GCC编译try.c所需的库路径。

2)用gcc进行编译
命令如下:
gcc -o try try.c -mms-bitfields -Ic:/gtk/include/gtk-2.0 -Ic:/gtk/lib/gtk-2.0/include -Ic:/gtk/include/atk-1.0 -Ic:/gtk/include/cairo -Ic:/gtk/include/pango-1.0 -Ic:/gtk/include/glib-2.0 -Ic:/gtk/lib/glib-2.0/include -Ic:/gtk/include/libpng12 -Lc:/gtk/lib -lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 -lgio-2.0 -lgdk_pixbuf-2.0 -lpangowin32-1.0 -lgdi32 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 -lintl

注意:gcc -o try try.c 后面跟着之前得到的两段库路径。

运行成功,生成try.exe
在命令行下执行结果:
GTK+界面设计_第1张图片

你可能感兴趣的:(QT及GTK+界面设计,嵌入式开发,表现层技术,DTV数字电视)