From 81d24111594460ac0e9927c3df51ccbbc28a6919 Mon Sep 17 00:00:00 2001 From: christoofar Date: Fri, 10 May 2024 10:31:39 -0500 Subject: [PATCH] Update README.md --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index c95df9b..2fe6c96 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,19 @@ Compile your program this way: This will statically link the lzma dependency from MSYS2 into your binary. +### Making a Windows binary from Linux/Docker + +You don't need Windows to make a Windows binary if you are developing in CGo. To do this, you need the MinGW64 GCC compiler: +``` +sudo apt-get install gcc-multilib +sudo apt-get install gcc-mingw-w64 +``` + +Then to build, just pass along the env setting to use the MinGW compiler +``` +GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ go build -ldflags "-extldflags \"-static\"" +``` + ## Usage ```go