Hi, I’m trying to use nix build for go project.
It has cgo flags configured in *.go file like this.
#cgo CFLAGS: -I${SRCDIR}/include -O2 ~~~
#cgo LDFLAGS: -L ${SRCDIR}/lib -lxxx -lyyy
When I enter nix develop and go build it works, but it doesn’t work with nix build
.
> /nix/store/7y75b2ac80chlh6knld3943y46n3v9kf-go-1.21.4/share/go/pkg/tool/linux_arm64/link: running gcc failed: exit status 1
> /nix/store/zzxh4c6lg7f04sav05h4hca94d4hch1m-binutils-2.40/bin/ld: cannot find -lxxx: No such file or directory
This issue is already mentioned in Go - NixOS Wiki (not 100% sure but looks similar). But have no idea how to fix this. Especially when I have *.so files in the source file which is not packaged in nix.
And I have additional CFLAGS in *.go file like -02
. Does all the cgo comments not work on nix?
Sorry for noob questions.