windows安装gtk2
2013-02-02 21:35:54 阿炯

GTK(GIMP Toolkit)是一套跨多种平台的图形工具包,按LGPL许可协议发布的。虽然最初是为GIMP写的,但目前已发展为一个功能强大、设计灵活的一个通用 图形库。特别是被GNOME选中使得GTK+广为流传,成为Linux下开发图形界面的应用程序的主流开发工具之一,当然GTK+并不要求必须在 Linux上,事实上目前GTK+已经有了成功的windows版本,下面就将介绍在windows平台安装gtk2开发环境。
方法一:从gnome官方提供源安装
下载地址为:
http://ftp.gnome.org/pub/gnome/binaries/win32/gtk+/

目前最新版本为:2.24/gtk+-bundle_2.24.10-20120208_win32.zip

解压缩到指定目录
我解压到'D:/programfiles/gtk2'

设置环境变量PATH
“我的电脑”--右键“属性”--“高级”--“环境变量”,编辑Path,添加:
D:/programfiles/gtk2/bin

测试
确保Windows系统内未安装其它版本的gtk+,在cmd命令行下执行:
pkg-config --cflags gtk+-2.0

结果:
-mms-bitfields -ID:/programfiles/gtk2/include/gtk-2.0 -ID:/programfiles/gtk2/lib/gtk-2.0/include -ID:/programfiles/gtk2/
include/atk-1.0 -ID:/programfiles/gtk2/include/cairo -ID:/programfiles/gtk2/include/gdk-pixbuf-2.0 -ID:/programfiles/gtk
2/include/pango-1.0 -ID:/programfiles/gtk2/include/glib-2.0 -ID:/programfiles/gtk2/lib/glib-2.0/include -ID:/programfile
s/gtk2/include -ID:/programfiles/gtk2/include/freetype2 -ID:/programfiles/gtk2/include/libpng14

注意:如果有其它版本的,先删除之。

验证安装是否正确
在cmd命令行下执行:
gtk-demo

应该会弹出一个窗口,其中有许多应用示例及其源代码。

方法二:使用'GTK+ for Windows Runtime Environment Installer'
其项目主页:http://gtk-win.sourceforge.net/home/index.php

上面所提供的二进制包对gtk的运行环境进行了一定的修改,使之更易用些,对一些在win32平台上使用的细节问题有改观。

Features:
 Easy to install
 Compatible with:
  Dropline's GTK (now discontinued). In fact, this site used to host it.
  The installer distributed with The Gimp (See Links).
  The installer distributed with Pidgin (See Links) (mostly).
 Can optionally set the "PATH" environment variable (or whatever it is called in the latest win32). This enables you to avoid writing names of every GTK+-using executable to registry.
 Includes the GTK+ default ("Raleigh"), Native ("Wimp") and Pixbuf theme engines. Native look is the default.
 Is "pure" in terms of bundling additional stuff. Only GTK+ and its requirements are bundled with it, no additional utilities or themes.

GTK+ Runtime installer contains the following software (or pieces of it):
 GTK+, ATK, Pango, GLib, gdk_pixbuf: http://www.gtk.org/;
 Cairo: http://cairographics.org/;
 Expat: http://expat.sourceforge.net/;
 Fontconfig: http://www.fontconfig.org/;
 Freetype2: http://www.freetype.org/;
 intl library (from gettext): http://www.gnu.org/software/gettext/;
 JPEG library: http://www.ijg.org/;
 libiconv: http://www.gnu.org/software/libiconv/;
 libpng: http://www.libpng.org/pub/png/libpng.html;
 LibTIFF: http://www.libtiff.org/;
 zlib: http://www.zlib.net/.

You may obtain the respective sources at the URLs listed above.

The binaries distributed with this package come from either their official sites (listed above), or from the following locations:
GTK+, ATK, Pango, GLib, gdk_pixbuf, Cairo and their dependencies can be obtained from http://ftp.gnome.org/pub/gnome/binaries/win32/. Most other binaries can be obtained from http://gnuwin32.sourceforge.net/.