From 7b5dd14927d9020045c48d63d9a5ae4832919711 Mon Sep 17 00:00:00 2001 From: hi20160616 <74967912+hi20160616@users.noreply.github.com> Date: Tue, 17 Aug 2021 23:56:38 +0800 Subject: [PATCH] Update README.md Section ####Other to windows (#348) * Update README.md section Ubuntu 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. * 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 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 9d5ef10..fa9aed5 100644 --- a/README.md +++ b/README.md @@ -330,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 ./ ```