Windows下GTK+的安装

本文档详细介绍了 GTK+ 图形界面库在 Windows 操作系统下的安装步骤及注意事项,包括如何选择合适的 GTK+ 版本,配置环境变量,以及在 MinGW 和 MSVC 编译环境下进行开发的方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  注意: GTK+ 3.x版本跟Python2.7不兼容,如果在Python下使用GTK,需要安装2.x版的gtk+ (在windows上如此)


对windows的64位系统下载这个2.22.1

[PARENTDIR] Parent Directory                                           -   
[   ] gtk+-bundle_2.22.0-20101016_win64.zip 2010-10-16 19:03   24M  
[   ] gtk+-bundle_2.22.1-20101229_win64.zip 2010-12-29 15:13   25M  
[   ] gtk+-dev_2.22.0-1_win64.zip           2010-10-01 23:11  4.2M  
[   ] gtk+-dev_2.22.1-1_win64.zip           2010-12-29 14:37  4.2M  
[   ] gtk+_2.22.0-1_win64.zip               2010-10-01 23:15  8.7M  
[   ] gtk+_2.22.1-1_win64.zip               2010-12-29 14:42  8.7M  

32位系统下载:2.24.10

[   ] gtk+-bundle_2.24.8-20111122_win32.zip  2011-11-23 22:15   24M  
[   ] gtk+-bundle_2.24.10-20120208_win32.zip 2012-02-08 22:24   24M  
[   ] gtk+-dev_2.24.0-1_win32.zip            2011-02-19 14:00  4.1M  
[   ] gtk+-dev_2.24.8-1_win32.zip            2011-11-23 22:16  4.1M  
[   ] gtk+-dev_2.24.10-1_win32.zip           2012-02-08 22:26  4.0M  
[   ] gtk+_2.24.0-1_win32.zip                2011-02-19 14:04  8.3M  
[   ] gtk+_2.24.8-1_win32.zip                2011-11-23 22:17  8.3M  
[   ] gtk+_2.24.10-1_win32.zip               2012-02-08 22:32  8.3M  


http://www.gtk.org/download/win32_tutorial.php

['', 'C:\\Windows\\system32\\python27.zip', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\\lib-tk', 'C:\\Python27\\Lib\\site-packages\\pythonwin', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages', 'C:\\Python27\\lib\\site-packages\\PIL', 'C:\\Python27\\lib\\site-packages\\gtk-2.0', 'C:\\Python27\\lib\\site-packages\\win32', 'C:\\Python27\\lib\\site-packages\\win32\\lib', 'C:\\Python27\\lib\\site-packages\\vlfd']
>>> 

Installation and usage tutorial for Windows

Releasing your program

You should always ship all needed DLLs & files with your binaries. End-users should not be required to download the bundle themselves.

Requirements

GTK+3 is known to work on Windows XP, Vista, 7 and 8 at this date. 

基本上windows xp以后的操作系统都能用

Developers might want to have a working MinGW or MSVC installation. 

取决于MinGW还是native的Visual studio

下载

[   ]gtk+-bundle_3.4.2-20130921_win32.zip21-Sep-2013 17:0829M 
[   ]gtk+-bundle_3.4.2-20131201_win64.zip01-Dec-2013 09:3030M 
[   ]gtk+-bundle_3.6.4-20130921_win32.zip21-Sep-2013 17:0829M 
[   ]gtk+-bundle_3.6.4-20131201_win64.zip01-Dec-2013 13:1631M 
[   ]gtk+-bundle_3.8.2-20131001_win32.zip01-Oct-2013 12:4229M 
[   ]gtk+-bundle_3.8.2-20131201_win64.zip01-Dec-2013 16:1431M 
[   ]gtk+-bundle_3.10.4-20131202_win32.zip02-Dec-2013 07:0627M 
[   ]gtk+-bundle_3.10.4-20131202_win64.zip

Initial setup

  1. Download the latest all-in-one bundle and extract it using right-click -> "Extract All...". Choose a location at your will ; we will call it %GTKDIR% during next phases. 下载all-in-one bundle,只须解压缩到工作文件夹即可

  2. Add %GTKDIR%\bin to your PATH environment variable : 须添加环境变量

    • Windows XP : right-click on "My Computer" -> "Properties".
    • Windows Vista/7 : right-click on "Computer" -> "Properties" -> "Advanced system settings".

    Click on "Advanced tab" -> "Environment variables". Double-click on PATH line in "System variables" panel, and add ;%GTKDIR%\bin at the end of the text.

  3. Optionally, open a console (Start -> Run -> "cmd" or Start -> search for "cmd") and type the following commands :

    • pango-querymodules > %GTKDIR%\etc\pango\pango.modules
    • gdk-pixbuf-query-loaders > %GTKDIR%\lib\gdk-pixbuf-2.0\2.10.0\loaders.cache
    • gtk-query-immodules-3.0 > %GTKDIR%\lib\gtk-3.0\3.0.0\immodules.cache

  4. Let's test ! Still in a console or in the "Run" window, run the demo : gtk3-demo 验证安装

Developing with GTK+3

MinGW 在windows下使用gcc编译器:

You should have a working installation, i.e. "gcc.exe" already in your PATH.

  1. In the console, verify that "pkg-config" prints out something reasonable by typing :

    pkg-config --cflags --libs gtk+-3.0

  2. Use this output in your further compilation commands, like this one :

    gcc -o gtk3.exe gtk3.c -mms-bitfields -Ic:/gtk3/include/gtk-3.0 -Ic:/gtk3/include/atk-1.0 -Ic:/gtk3/include/cairo [...]

  3. Test the resulting executable (here gtk3.exe) :

MSVC 使用visual studio的情况下:
  1. Open the Visual Studio Command Prompt :

  2. In the console, verify that "pkg-config" prints out something reasonable by typing :

    pkg-config --cflags gtk+-3.0

  3. Use this output in your further compilation commands, like this one, modifying the following : 

    • delete the "-mms-bitfields" switch ;
    • add the "-Dinline= /link /libpath:%GTKDIR% gtk-win32-3.0.lib gobject-2.0.lib" switches at the end.

    For instance :

    cl gtk3.c -mms-bitfields -Ic:/gtk3/include/gtk-3.0 -Ic:/gtk3/include/atk-1.0 [...] -Dinline= /link /libpath:c:/gtk3/lib gtk-win32-3.0.lib gobject-2.0.lib

    ("gtk-win32-3.0.lib gobject-2.0.lib" are a minimal requirement. You may want to add other .lib files as you need them)

  4. Test the resulting executable (here gtk3.exe) :


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值