DEV Community

Discussion on: Zig Makes Go Cross Compilation Just Work

Collapse
 
amarting profile image
Alvaro Martin

Hi, I am running all the commands above.
Process:
brew install zig
added zip dir to path
building docker image (linux/amd64) of go1.18.2-alpine3.14 (so same as the example, with go 1.18 or above) on a macbook m1 machine.

RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC="zig cc -target x86_64-linux" CXX="zig c++ -target x86_64-linux" \
go build --tags extended -ldflags="-w -s" -o app.go

Getting this error:

runtime/cgo

cgo: C compiler "zig" not found: exec: "zig": executable file not found in $PATH

Anyone knows what might be wrong? Any direction?
Thanks!