Trying to cross compile on macos arm for linux. My sample project looks like this:
main.go:
package main
import(
"github.com/apple/foundationdb/bindings/go/src/fdb"
)
func main() {
fdb.APIVersion(630)
fdb.MustOpenDatabase("fdb.cluster")
}
go.mod
module fdbtest
go 1.19
require github.com/apple/foundationdb/bindings/go v0.0.0-20221026173525-97cc643cef69
require golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect
go.sum
github.com/apple/foundationdb/bindings/go v0.0.0-20221026173525-97cc643cef69 h1:vG55CLKOUgyuD15KWMxqRgTPNs8qQfXPtWjYYN5Wai0=
github.com/apple/foundationdb/bindings/go v0.0.0-20221026173525-97cc643cef69/go.mod h1:w63jdZTFCtvdjsUj5yrdKgjxaAD5uXQX6hJ7EaiLFRs=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
I've installed foundationdb go lang bindings via go get github.com/apple/foundationdb/bindings/[email protected]
but when I do env GOOS=linux GOARCH=amd64 go build
I get the following errors:
env GOOS=linux GOARCH=amd64 go build
# github.com/apple/foundationdb/bindings/go/src/fdb
../../../go/pkg/mod/github.com/apple/foundationdb/bindings/[email protected]/src/fdb/keyselector.go:39:10: undefined: KeyConvertible
../../../go/pkg/mod/github.com/apple/foundationdb/bindings/[email protected]/src/fdb/snapshot.go:33:3: undefined: transaction
../../../go/pkg/mod/github.com/apple/foundationdb/bindings/[email protected]/src/fdb/generated.go:45:9: undefined: NetworkOptions
<...>
../../../go/pkg/mod/github.com/apple/foundationdb/bindings/[email protected]/src/fdb/generated.go:94:9: too many errors
So it seems that it cannot find any of the types from fdb. Yet the KeyConvertible
and the NetworkOptions
(and others) exist in ../../../go/pkg/mod/github.com/apple/foundationdb/bindings/[email protected]/src/fdb/fdb.go
My golang version: go version go1.19.3 darwin/arm64
Newer fdb go bindings (7.1.25, 7.1.0) seem to behave the same...
what am I missing here?
arm64 architecture installations may be problematic but you should also check some requirements.
In my case with amd64 architecture the default Ubuntu installation for Windows 11 WSL2 was missing some dependencies:
After installing the above packages the errors were gone.
See more details at https://forums.foundationdb.org/t/golang-errors-finding-github-com-apple-foundationdb-bindings-go-src-fdb/4133