Home > Article > Backend Development > Unable to run Golang application on 32-bit machine
php editor Yuzai pointed out that recently some users reported the problem of being unable to run Golang applications on 32-bit machines. After investigation, it was found that this is because the Golang language was originally designed to run on 64-bit systems, and the address space of 32-bit systems is limited and cannot meet the needs of Golang. Therefore, if you want to run Golang applications on a 32-bit machine, you may want to consider upgrading to a 64-bit system, or use other programming languages that are suitable for 32-bit systems to develop applications.
I built Golang as a 32-bit version on a 64-bit machine. However, it has a problem, when I build like this, it gets the "kernel32.dll" in the SysWOW64 folder, but when I run it in a 32-bit machine (Windows 7). It doesn't have a SysWOW64 folder, so it returns the error:
Fatal error: kernel32.dll not found
This is my go build command:
go build -ldflags "-s -w"
This is my environment:
set GO111MODULE= set GOARCH=386 set GOBIN= set GOCACHE=C:\Users\name\AppData\Local\go-build set GOENV=C:\Users\name\AppData\Roaming\go\env set GOEXE=.exe set GOEXPERIMENT= set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOINSECURE= set GOMODCACHE=C:\Users\name\go\pkg\mod set GONOPROXY= set GONOSUMDB= set GOOS=windows set GOPATH=C:\Users\name\go set GOPRIVATE= set GOPROXY=https://proxy.golang.org,direct set GOROOT=C:\Program Files\Go set GOSUMDB=sum.golang.org set GOTMPDIR= set GOTOOLCHAIN=auto set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64 set GOVCS= set GOVERSION=go1.21.1 set GCCGO=gccgo set GO386=sse2 set AR=ar set CC=gcc set CXX=g++ set CGO_ENABLED=1 set GOMOD=D:\Center\go.mod set GOWORK= set CGO_CFLAGS=-O2 -g set CGO_CPPFLAGS= set CGO_CXXFLAGS=-O2 -g set CGO_FFLAGS=-O2 -g set CGO_LDFLAGS=-O2 -MT set PKG_CONFIG=pkg-config set GOGCCFLAGS=-m32 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\name\AppData\Local\Temp\go-build581533674=/tmp/go-build -gno-record-gcc-switches
Can anyone suggest me a solution?
According to phuclv's answer: "SysWOW64
is a 32-bit System32 on 64-bit Windows. 32-bit applications have to use %windir%\System32 All access to will be redirected to %windir%\SysWOW64."
So I think in your case you need to build a 32 bit machine (or virtual machine) and then copy and build your code over there. Of course, you'll have to downgrade some libraries to match the operating system, which can be challenging sometimes.
The above is the detailed content of Unable to run Golang application on 32-bit machine. For more information, please follow other related articles on the PHP Chinese website!