how to build Golang for windows xp in Ubuntu?

338 views Asked by At

how to build Golang for windows xp in Ubuntu?

Golang Version: Go 1.13
Ubuntu Version: Ubuntu 20.04.5 LTS (Focal Fossa)
Mingw-w64 Version: 9.3 / 7.0.0-2

enter image description here

command:
GOOS=windows GOARCH=386 CC=i686-w64-mingw32-gcc CGO_ENABLED=1 go build -o test.exe

enter image description here

In Windows XP Error:
"Not a valid win32 application"

thank you

1

There are 1 answers

0
sangwook.ahn On

It seems you have to use go version 1.10.8 to build Golang on Windows XP.

golang 1.10.8

wget https://dl.google.com/go/go1.10.linux-amd64.tar.gz
sudo tar -xvf go1.10.linux-amd64.tar.gz
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$GOROOT/bin:$PATH

I thought there might be another way, but there is none other than this.