When I try to cross compile my golang project from OSX to Linux, then I get following error message:
# runtime/cgo
ld: unknown option: --build-id=none
clang: error: linker command failed
and the compilation aborts.
This is how I try to build my application:
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build
I also tried using gox:
gox -os="linux"
but it still did not work.
Everything works as expected if I do not use the GOOS=linux tag and I am able to build/run my project for/on my OSX machine successfully.
Imageis declared?Imageis in a file that uses cgo, and you're not compiling with cgo. Do you also have the complete toolchain installed to cross-compile C code to Linux?CGO_ENABLED=1and there are no build constraints in the source, and it's still not there, what is the name of the file?CC_FOR_TARGETandCXX_FOR_TARGETto specify them (look for "cross-compiling" in the docs here). It's probably much easier to build this in a docker container than trying to get cross compilation running.