Can not run on debian/Ubuntu
xiebruce opened this issue · comments
Bruce commented
executable that build with the follow command can run on alpine(which is inside my docker container)
env CC=x86_64-linux-musl-gcc CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -ldflags "-w -s" -o "Hello2-Linux"
but can not run on Debian/Ubuntu, it returns error:
bash: ./Hello2-Linux: No such file or directory
So how can I build executables that can run on debian/Ubuntu etc.
Filippo Valsorda commented
Add -extldflags=-static
to build a static binary that doesn't link dynamically against musl libc.