FiloSottile / homebrew-musl-cross

Homebrew Formula for static-friendly musl-based GCC macOS-to-Linux cross-compilers
https://blog.filippo.io/easy-windows-and-linux-cross-compilers-for-macos/
ISC License
547 stars 45 forks source link

Can not run on debian/Ubuntu #42

Closed xiebruce closed 1 year ago

xiebruce commented 1 year ago

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.

FiloSottile commented 1 year ago

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