Windows 10使用gvsbuild安装配置GTK

根据GTK官方网站Setting up GTK for Windows,在Windows上安装GTK有两种方法,一种是使用MSYS,这种方法较为简单,在此不表;另一种是使用gvsbuild,较为复杂,流程如下:

  1. 安装dependencies,可在gvsbuild查看,当前版本为:Visual Studio 2019(2015及以上版本)、MSYS2 64、Python 3.9.2(3.6及以上版本)。更新MSYS2的包。
  2. 将该库克隆到C:\gtk-build\github\gvsbuild,注意该路径不可更改,因为生成脚本规定如此。
  3. 在PowerShell(CMD也可)中切换到该目录下并运行生成脚本:
    cd C:\gtk-build\github\gvsbuild
    python .\build.py build -p x64 --vs-ver 16 gtk3 --msys-dir='E:\Program_Files\msys64' --vs-install-path='D:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise'

    其中-p -x64指定生成64位版本(默认为32位),--vs-ver 16指定VS生成工具版本为2019(2017版本号为15,2015版本号为14,2013版本号为12,默认为12)。注意脚本默认MSYS路径为C:\Msys64,所以需要手动指定你自己的MSYS安装路径;VS路径默认为C:\Program Files (x86)\Microsoft Visual Studio\\20xx,所以需要手动指定你自己的VS安装路径。详情可见源代码gvsbuild/parser.py at master · wingtk/gvsbuild (github.com)。脚本执行信息如下:

    Cleaning up the build environment
    Checking msys tool
    Checking Msvc tool
    Downloading packages
    C:\gtk-build\src\nuget-5.4.0.exe - Download finished
    C:\gtk-build\src\ninja-win-1.8.2.zip - Download finished
    C:\gtk-build\src\meson-0.57.1.tar.gz - Download finished
    C:\gtk-build\src\cmake-3.20.0-windows-x86_64.zip - Download finished
    C:\gtk-build\src\win-iconv-0.0.8.tar.gz - Download finished
    C:\gtk-build\src\gettext-0.19.7.tar.gz - Download finished
    C:\gtk-build\src\zlib-1.2.11.tar.xz - Download finished
    C:\gtk-build\src\glib-2.68.1.tar.xz - Download finished
    C:\gtk-build\src\atk-2.36.0.tar.xz - Download finished
    C:\gtk-build\src\nasm-2.13.03-win64.zip - Download finished
    C:\gtk-build\src\libjpeg-turbo-2.0.6.tar.gz - Download finished
    C:\gtk-build\src\tiff-4.2.0.tar.gz - Download finished
    C:\gtk-build\src\jasper-2.0.14.tar.gz - Download finished
    C:\gtk-build\src\libpng-1.6.37.tar.xz - Download finished
    C:\gtk-build\src\gdk-pixbuf-2.42.6.tar.xz - Download finished
    Opening http://git.savannah.gnu.org/cgit/freetype/freetype2.git/snapshot/freetype2-0d5f1dd37c056b4460a460d16fd1fbb06740e
    C:\gtk-build\src\freetype2-0d5f1dd37c056b4460a460d16fd1fbb06740e891.tar.gz - Download finished
    C:\gtk-build\src\libxml2-2.9.10.tar.gz - Download finished
    C:\gtk-build\src\fontconfig-2.13.0.tar.gz - Download finished
    C:\gtk-build\src\pixman-0.40.0.tar.gz - Download finished
    C:\gtk-build\src\cairo-1.16.0.tar.xz - Download finished
    C:\gtk-build\src\harfbuzz-2.8.0.tar.xz - Download finished
    C:\gtk-build\src\pango-1.48.4.tar.xz - Download finished
    C:\gtk-build\src\libepoxy-1.5.5.tar.xz - Download finished
    C:\gtk-build\src\gtk+-3.24.28.tar.xz - Download finished
    Building project nuget (5.4.0)
    Feeds used:
      C:\Users\Yihua\.nuget\packages\
      https://api.nuget.org/v3/index.json
      C:\Users\Yihua\AppData\Local\Esri\NuGet
      C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\

    Attempting to gather dependency information for package 'python.3.9.2' with respect to project 'C:\gtk-build\tools', targeting 'Any,Version=v0.0'
    Gathering dependency information took 1.72 sec
    Attempting to resolve dependencies for package 'python.3.9.2' with DependencyBehavior 'Lowest'
    Resolving dependency information took 0 ms
    Resolving actions to install package 'python.3.9.2'
    Resolved actions to install package 'python.3.9.2'
    Retrieving package 'python 3.9.2' from 'nuget.org'.
      GET https://api.nuget.org/v3-flatcontainer/python/3.9.2/python.3.9.2.nupkg
      OK https://api.nuget.org/v3-flatcontainer/python/3.9.2/python.3.9.2.nupkg 835ms
    Installing python 3.9.2.
    Adding package 'python.3.9.2' to folder 'C:\gtk-build\tools'
    Added package 'python.3.9.2' to folder 'C:\gtk-build\tools'
    Successfully installed 'python 3.9.2' to C:\gtk-build\tools
    Executing nuget actions took 9.26 sec
    Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
    Collecting pip
      Downloading https://pypi.tuna.tsinghua.edu.cn/packages/cd/6f/43037c7bcc8bd8ba7c9074256b1a11596daa15555808ec748048c1507f08/pip-21.1.1-py3-none-any.whl (1.5 MB)
         |████████████████████████████████| 1.5 MB 939 kB/s
    Installing collected packages: pip
      Attempting uninstall: pip
        Found existing installation: pip 20.2.3
        Uninstalling pip-20.2.3:
          Successfully uninstalled pip-20.2.3
    Successfully installed pip-21.1.1
    Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
    Requirement already satisfied: setuptools in c:\gtk-build\tools\python.3.9.2\tools\lib\site-packages (49.2.1)
    ……

注意如果你为git设置了代理,中间python pip安装时代理会报错,需要关代理重新build,然后又会执行git clone操作因无代理而失败,需要开代理重新build,然后就开始编译了。注意:当前版本的wingtk有个bug,会导致编译错误

Traceback (most recent call last):
  File "C:\gtk-build\github\gvsbuild\gvsbuild\utils\builder.py", line 492, in build
    if self.__build_one(p):
  File "C:\gtk-build\github\gvsbuild\gvsbuild\utils\builder.py", line 618, in __build_one
    skip_deps = proj.build()
  File "C:\gtk-build\github\gvsbuild\gvsbuild\projects.py", line 347, in build
    content = f.read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0xbf in position 2: illegal multibyte sequence
Error: fontconfig build failed

详情可见Issue #411Pull Request #408,目前该PR尚未merge,可以在本地根据该PR修改projects.py后即可编译。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Ayka

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值