Skip to content

Instantly share code, notes, and snippets.

@yordanoweb
Last active February 23, 2025 16:23
Show Gist options
  • Select an option

  • Save yordanoweb/9d77fb2b482ed446ba976e0d99e9305d to your computer and use it in GitHub Desktop.

Select an option

Save yordanoweb/9d77fb2b482ed446ba976e0d99e9305d to your computer and use it in GitHub Desktop.
Compile Go for Windows from Linux

Compile to Windows executable from Linux

Install zig

By any means, using default distro package manager, or any other method, install zig. Please, install zig first...

Compile project

CGO_ENABLED=1 \
    GOOS=windows \
    GOARCH=amd64 \
    CC="zig cc -target x86_64-windows" \
    CXX="zig c++ -target x86_64-windows" \
    go build --tags extended -o app-x86_64.exe

After this...

I copied the project with its database and other dependencies in static folder, and other assets folder, and went to a Windows 10 machine. Then I double clicked over the EXE file, and everything worked fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment