gtk:gtk+-bundle_2.24.10-20120208_win32
IDE:vs2008
OS:WIN xp
1、下载gtk All-in-one bundle 包
登录 www.gtk.org官网,download,选择win32或者win64,在下方有All-in-one bundle 的链接,点击下载。
2、设置环境变量
假设你解压到了e:\work 目录下,将E:\work\gtk+-bundle_2.24.10-20120208_win32\bin 加入到PATH环境变量中。bin目录中包含有run time所需的dll文件,其中也包括gtk-demo示例程序。
3、测试运行
运行E:\work\gtk+-bundle_2.24.10-20120208_win32\bin\gtk-demo 示例程序,应可以看到程序的窗口界面
4、配置VS2008 include目录
新建一个控制台空工程,设置工程属性
不能只简单的包含E:\work\gtk+-bundle_2.24.10-20120208_win32\include,因为它下面还嵌套了好多目录。除include目录外,在lib目录下,也有两个.h文件需要包含。这是我的附加包含目录:D:\Program Files\gtk+-bundle_2.24.10-20120208_win32\include\gtk-2.0;D:\Program Files\gtk+-bundle_2.24.10-20120208_win32\include\atk-1.0;;D:\Program Files\gtk+-bundle_2.24.10-20120208_win32\include\freetype2;D:\Program Files\gtk+-bundle_2.24.10-20120208_win32\include\gail-1.0;D:\Program Files\gtk+-bundle_2.24.10-20120208_win32\include\gdk-pixbuf-2.0;D:\Program Files\gtk+-bundle_2.24.10-20120208_win32\include\gio-win32-2.0;D:\Program Files\gtk+-bundle_2.24.10-20120208_win32\include\glib-2.0;D:\Program Files\gtk+-bundle_2.24.10-20120208_win32\include\pango-1.0;D:\Program Files\gtk+-bundle_2.24.10-20120208_win32\include;D:\Program Files\gtk+-bundle_2.24.10-20120208_win32\include\cairo;E:\work\gtk+-bundle_2.24.10-20120208_win32\lib\gtk-2.0\include;E:\work\gtk+-bundle_2.24.10-20120208_win32\lib\glib-2.0\include
5、配置工程的lib目录
我的附加库目录:D:\Program Files\gtk+-bundle_2.24.10-20120208_win32\lib
将lib目录下的所有.lib文件都放到附加依赖项中,包括:atk-1.0.lib gdk_pixbuf-2.0.lib gthread-2.0.lib pangoft2-1.0.lib cairo.lib gdk-win32-2.0.lib gtk-win32-2.0.lib pangowin32-1.0.lib expat.lib gio-2.0.lib intl.lib zdll.lib fontconfig.lib glib-2.0.lib libpng.lib freetype.lib gmodule-2.0.lib pango-1.0.lib gailutil.lib gobject-2.0.lib pangocairo-1.0.lib
6、hello world
#include "gtk/gtk.h"
int main(int argc, char *argv[])
{
GtkWidget *window;
gtk_init(&argc, &argv);
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect(G_OBJECT(window), "destroy",
G_CALLBACK(gtk_main_quit), NULL);
gtk_widget_show(window);
gtk_main();
return 0;
}
运行