Sqlite3 dependency error during cross compile

I’m on Mac OS, and I can produce a darwin binary perfectly fine by running:

go run build.go setup
go run build.go build

Now, on Mac OS, I want to cross compile a go binary for Linux, so I run:

go run build.go -goos=“linux” setup
go run build.go -goos=“linux” build

Setup appears to work, but build gives me the following output:

Version: 4.4.1, Linux Version: 4.4.1, Package Iteration: 1499978314
rm -r dist
rm -r tmp
rm -r /Users/localadmin/go2/pkg/linux_amd64/github.com/grafana
rm -r ./bin/grafana-server
rm -r ./bin/grafana-server.md5
go version
go version go1.8 darwin/amd64
go build -ldflags -w -X main.version=4.4.1 -X main.commit=9341412 -X main.buildstamp=1499285160 -o ./bin/grafana-server ./pkg/cmd/grafana-server
pkg/services/sqlstore/shared.go:44: undefined: sqlite3.Error
pkg/services/sqlstore/shared.go:45: undefined: sqlite3.ErrLocked
exit status 2
exit status 1

I then tried “go get github.com/mattn/go-sqlite3” to resolve the dependency but same error occurred when I ran build.

You can’t cross compile sadly, or extremely tricky with cgo dependencies.

I did do a test with https://github.com/karalabe/xgo and looks promising.

Your easiest solution is to spin up a Linux docker container and build it there

Will do, thanks for the reply.

hi, i have the same question .
did you resolve that ?