3

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/go@6.3.25

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/go@v0.0.0-20221026173525-97cc643cef69/src/fdb/keyselector.go:39:10: undefined: KeyConvertible
../../../go/pkg/mod/github.com/apple/foundationdb/bindings/go@v0.0.0-20221026173525-97cc643cef69/src/fdb/snapshot.go:33:3: undefined: transaction
../../../go/pkg/mod/github.com/apple/foundationdb/bindings/go@v0.0.0-20221026173525-97cc643cef69/src/fdb/generated.go:45:9: undefined: NetworkOptions
<...>
../../../go/pkg/mod/github.com/apple/foundationdb/bindings/go@v0.0.0-20221026173525-97cc643cef69/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/go@v0.0.0-20221026173525-97cc643cef69/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?

gerasalus
  • 7,538
  • 6
  • 44
  • 66

2 Answers2

0

If you follow https://github.com/apple/foundationdb/tree/main/bindings/go you can see how to install the package properly.

danthegoodman
  • 501
  • 4
  • 10
0

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:

  • mono
  • libc6
  • cmake

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

manfontan
  • 11
  • 3