在Darwin for Linux上交叉编译CGO应用

I'm having issues trying to cross-compile a Go app on OS X to run on linux/amd64. The app in question is using libvips via this vips go package. As such, it is using CGO and needs to be compiled with CGO support.

I'm on Go 1.4 and running the following build command

GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build

but end up with a linker error

ld: unknown option: --build-id=none clang: error: linker command failed with exit code 1 (use -v to see invocation)

I'm assuming I probably need to add some kind of -ldflags argument but am not sure.

Is it possible to cross-compile CGO apps in this manner yet, or do I need to do a native-build on the target system to avoid issues and headaches?

Have a look at gonative. this allows you to cross-compile cgo code (as long as you are just using the stdlib).

Another approach would be to compile the linux binary using docker.