错误提示

% fyne package -name report-bot -os windows -icon samans_logo.png
# runtime/cgo
gcc_libinit_windows.c:8:10: fatal error: 'windows.h' file not found

尝试用 gcc 编译一下,首先替换掉默认的 clang

mingw

Minimalist GNU for Windows and GCC cross-compilers
因为是 mac 系统所以要安装第三方修改的版本

安装 gcc

Mac 系统直接食用 homebrew 安装

brew install mingw-w64

更改 golang 环境变量

go env

basic
GOVERSION="go1.17.7"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/laur

更改 CC

# fyne 官网推荐配置 
# https://developer.fyne.io/started/cross-compiling#compiling-from-a-development-computer
go env -w CC=x86_64-w64-mingw64-gcc

重新运行

fyne package -name report-bot -os windows -icon samans_logo.png

可以成功打包没有报错但是在 windows 运行后无效果,可能是需要 windows 系统的支持

结果在 fyne-cross 的页面看到了提示 https://github.com/fyne-io/fyne-cross

  • iOS compilation is supported only on darwin hosts. See fyne pre-requisites for details.
  • macOS packaging for public distrubution (release mode) is supported only on darwin hosts.
  • windows packaging for public distrubution (release mode) is supported only on windows hosts.

嗯。。。老实去 windows 系统打包可以用了

但是我得吐槽一遍

为什么他妈的我在 mac 系统 go env 的 proxy 是 proxy.org,direct 可以用,在 windows 上挂了全局的梯子还是不能啊

虽然环境花了两个多小时,但学会了如何配置 windows 的系统变量……