Cross compile Linux->Windows. gtk-rs

I have a Linux machine, and don’t have a Windows machine, yet I want to compile my gtk-rs program to create a Windows executable file. I also want to able to run it on Windows 7, if possible.

The best I’ve found is this 5-year-old docker image which I didn’t test, does it still work? (There would be some “difficulties” in testing it, so I would like a confirmation that still up-to-date before I test it)

OS: Pop!_OS 24.04 (essentially Ubuntu 24.04 with newer kernel).

The error I get:

doods@pop-os ~/.d/p/gtk_test (master)> cargo build --target=x86_64-pc-windows-gnu --release
   Compiling glib-sys v0.20.7
   Compiling gobject-sys v0.20.7
   Compiling gio-sys v0.20.8
   Compiling glib-macros v0.20.7
warning: gobject-sys@0.20.7: pkg-config has not been configured to support cross-compilation.
error: failed to run custom build command for `gobject-sys v0.20.7`

Caused by:
  process didn't exit successfully: `/home/doods/.dev/projects/gtk_test/target/release/build/gobject-sys-1562f12c532d758a/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-changed=/home/doods/.dev/rust/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/gobject-sys-0.20.7/Cargo.toml
  cargo:rerun-if-env-changed=GOBJECT_2.0_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64-pc-windows-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64_pc_windows_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-pc-windows-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_pc_windows_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-pc-windows-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_pc_windows_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:warning=pkg-config has not been configured to support cross-compilation.

  Install a sysroot for the target platform and configure it via
  PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a
  cross-compiling wrapper for pkg-config and set it via
  PKG_CONFIG environment variable.
warning: build failed, waiting for other jobs to finish...
warning: glib-sys@0.20.7: pkg-config has not been configured to support cross-compilation.
error: failed to run custom build command for `glib-sys v0.20.7`

Caused by:
  process didn't exit successfully: `/home/doods/.dev/projects/gtk_test/target/release/build/glib-sys-bb3582abae26e83f/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-changed=/home/doods/.dev/rust/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/glib-sys-0.20.7/Cargo.toml
  cargo:rerun-if-env-changed=GLIB_2.0_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64-pc-windows-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64_pc_windows_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-pc-windows-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_pc_windows_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-pc-windows-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_pc_windows_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:warning=pkg-config has not been configured to support cross-compilation.

  Install a sysroot for the target platform and configure it via
  PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a
  cross-compiling wrapper for pkg-config and set it via
  PKG_CONFIG environment variable.
warning: gio-sys@0.20.8: pkg-config has not been configured to support cross-compilation.
error: failed to run custom build command for `gio-sys v0.20.8`

Caused by:
  process didn't exit successfully: `/home/doods/.dev/projects/gtk_test/target/release/build/gio-sys-d12353726f226b79/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-changed=/home/doods/.dev/rust/cargo/registry/src/index.crates.io-1949cf8c6b5b557f/gio-sys-0.20.8/Cargo.toml
  cargo:rerun-if-env-changed=GIO_2.0_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64-pc-windows-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS_x86_64_pc_windows_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_ALLOW_CROSS
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-pc-windows-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_pc_windows_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-pc-windows-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_pc_windows_gnu
  cargo:rerun-if-env-changed=TARGET_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:warning=pkg-config has not been configured to support cross-compilation.

  Install a sysroot for the target platform and configure it via
  PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a
  cross-compiling wrapper for pkg-config and set it via
  PKG_CONFIG environment variable.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.