mac m1 golang 交叉编译windows amd64程序,解决方式

brew install mingw-w64
brew --prefix mingw-w64

依赖zlib库
zlib 下载地址
sudo copy zlib-1.2.5-bin-x64/bin/* /opt/homebrew/opt/mingw-w64/toolchain-x86_64/x86_64-w64-mingw32/bin
sudo copy zlib-1.2.5-bin-x64/include/* /opt/homebrew/opt/mingw-w64/toolchain-x86_64/x86_64-w64-mingw32/include
sudo copy zlib-1.2.5-bin-x64/lib/* /opt/homebrew/opt/mingw-w64/toolchain-x86_64/x86_64-w64-mingw32/lib

GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ go build -x -v -ldflags “-H=windowsgui” -o daka.exe main.go

我几年前提交的issues
https://github.com/go-vgo/robotgo/issues/283

你可能感兴趣的:(golang,macos,windows)