my go env
GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOOS="linux" GOPATH="" GORACE="" GOROOT="/usr/local/go" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GO15VENDOREXPERIMENT="" CC="gcc" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0" CXX="g++" CGO_ENABLED="1"
I compiled and successfully executed the binary on my mac and then copied it to the ubuntu machine whose go env is show above. When I call myprog binary, I get
bash: /usr/local/go/bin/myprog: cannot execute binary file: Exec format error
Since go 1.5, cross compiler has gotten pretty easy. Something like
env GOOS=linux GOARCH=amd64 go build -v github.com/constabulary/gb/cmd/gb
Refer to http://dave.cheney.net/2015/08/22/cross-compilation-with-go-1-5.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With