1、安装相关依赖的包
sudo apt-get install gnome-core-devel sudo apt-get install libglib2.0-doc libgtk2.0-doc sudo apt-get install devhelp sudo apt-get install glade-gnome glade-common glade-doc
2、如何方便的输入GTK+的include、lib依赖
#有一个命令可以方便搞定GTK+的include、lib依赖 pkg-config --cflags --libs gtk+-2.0
3、在Eclipse中配置
(1)右键项目->Properties->C/C++ Build->Settings->GCC C Compiler->Miscellaneous,加入`pkg-config --cflags --libs gtk+-2.0`
(2)右键项目->Properties->C/C++ Build->Settings->GCC C Linker>Miscellaneous,加入`pkg-config --cflags --libs gtk+-2.0`
(3)右键项目->Properties->C/C++ Build->Settings->GCC C Compiler->Directories,加入/usr/include/gtk-2.0 和 /usr/include/glib-2.0 这个是为了方便智能提示。
4、测试程序
#include <gtk/gtk.h> int main(int argc, char *argv[]) { GtkWidget *window; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_show(window); gtk_main(); return 0; }
最后,一个很好的GTK+教程:
http://zetcode.com/tutorials/gtktutorial/chinese/