为 Windows 交叉编译 gtk crate

Cross-compile gtk crate for Windows

我想使用 gtk crate 为 Windows 编写一个小的图形用户界面应用程序。我想知道是否有机会将它从我的 Linux 机器交叉编译到 Windows.

当我尝试使用 PKG_CONFIG_SYSROOT_DIR=/usr/x86_64-w64-mingw32 cargo build --target x86_64-pc-windows-gnu 针对 x86_64-pc-windows-gnu 目标编译我的代码时,出现以下错误:

error: linking with `x86_64-w64-mingw32-gcc` failed: exit status: 1
  |
[...]
  = note: /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgobject-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgtk-3
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgdk-3
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lpangocairo-1.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lpango-1.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lharfbuzz
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -latk-1.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lcairo-gobject
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lcairo
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgdk_pixbuf-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgio-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgobject-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lglib-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -latk-1.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgobject-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lglib-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgdk-3
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lpangocairo-1.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lpango-1.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lharfbuzz
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgdk_pixbuf-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lcairo-gobject
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lcairo
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgobject-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lglib-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lpango-1.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgobject-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lglib-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lharfbuzz
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgdk_pixbuf-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgobject-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lglib-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgio-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgobject-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lglib-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lcairo-gobject
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lcairo
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgobject-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lglib-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgobject-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lglib-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lgobject-2.0
          /usr/bin/x86_64-w64-mingw32-ld: cannot find -lglib-2.0
          collect2: error: ld returned 1 exit status

我似乎缺少 Windows 的 gtk 库文件,但我不确定我应该做什么或如何获得这些文件。

我设法使用this awesome tool编译了它。

基本上它是 dockerized Linux Fedora 具有所有必要的依赖项 pre-installed。