From 183f505e94f2add8f8fa7f6f6b76b7a9e1072bc8 Mon Sep 17 00:00:00 2001 From: hi20160616 <74967912+hi20160616@users.noreply.github.com> Date: Tue, 17 Aug 2021 17:52:44 +0800 Subject: [PATCH] Update README.md section #### Other to windows I'd try and pass test for cross-compile on ubuntu to windows i386 and x86_64, my case: https://github.com/hi20160616/robotclick/blob/main/.github/workflows/goreleaser.yml. I dig and read many issues here, and collect the right way to cross-compile for windows binary. I think it will help someone like me to fix bugs while cross compile. like error `zlib.h cannot find out` usually because of we installed it via source, that not useful on **mingw-w64**. I also suggest this update to let newbee easy to use this grand code. --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1f41ddd..fa9aed5 100644 --- a/README.md +++ b/README.md @@ -88,10 +88,6 @@ sudo apt install xcb libxcb-xkb-dev x11-xkb-utils libx11-xcb-dev libxkbcommon-x1 sudo apt install libxkbcommon-dev sudo apt install xsel xclip - -sudo apt-get install gcc-multilib -sudo apt-get install gcc-mingw-w64 -sudo apt install libz-mingw-w64-dev ``` #### Fedora: @@ -334,6 +330,14 @@ go build main.go ``` #### Other to windows +Install Requirements: +```bash +sudo apt-get install gcc-multilib +sudo apt-get install gcc-mingw-w64 +# fix err: zlib.h: No such file or directory +sudo apt-get install libz-mingw-w64-dev +``` +Build the binary: ```Go GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ go build -x ./ ```