Closed laszlocph closed 3 years ago
there's currently no way to make this library work with CGO_ENABLED=0
:( per https://golang.org/cmd/cgo/
The cgo tool is enabled by default for native builds on systems where it is expected to work. It is disabled by default when cross-compiling. You can control this by setting the
CGO_ENABLED
environment variable when running the go tool: set it to 1 to enable the use of cgo, and to 0 to disable it. The go tool will set the build constraint "cgo" if cgo is enabled. The special import "C" implies the "cgo" build constraint, as though the file also said "// +build cgo". Therefore, if cgo is disabled, files that import "C" will not be built by the go tool. (For more about build constraints see https://golang.org/pkg/go/build/#hdr-Build_Constraints).
That is fine, and thanks for the super quick answer!
Lol, I should have just look up what is CGO. It is what makes the whole project possible. Silly me. Thanks!
Hi,
I followed the
Versioned branch, static linking
guide, and the project builds withgo build
.However when I try to package my software with
CGO_ENABLED=0
I get a C compile error.The command:
The repro case: https://github.com/gimlet-io/gimlet-cli/runs/1453818829?check_suite_focus=true
My knowledge is shallow around linking and cgo, should this work at all?
Thank you, Laszlo