FiloSottile / homebrew-musl-cross

Homebrew Formula for static-friendly musl-based GCC macOS-to-Linux cross-compilers

Home Page:https://blog.filippo.io/easy-windows-and-linux-cross-compilers-for-macos/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can not run on debian/Ubuntu

xiebruce opened this issue · comments

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.

Add -extldflags=-static to build a static binary that doesn't link dynamically against musl libc.