Undefined: NetworkOptions


(John Li) #1

I was cross building for linux/amd64 on MacOS and running this error, any idea? I am using FoundatationDB bindings release 5.2 branch.

–> linux/amd64:

1 errors occurred:
–> linux/amd64 error: exit status 2

…/…/apple/foundationdb/bindings/go/src/fdb/generated.go:28:9: undefined: NetworkOptions

It is weired that the NetworkOptions is defined …/…/apple/foundationdb/bindings/go/src/fdb/fdb.go which is is in the same package as generated.go sits.

(A.J. Beamon) #2

How are you building the bindings?

(Mathieu Hinderyckx) #3

I am facing the same issue while trying to package our FoundationDB client program in a container, and have not found a working solution for this after hours of frustration. My Dockerfile looks somewhat like this

FROM ubuntu:18.04

RUN apt-get update && apt-get install -y git golang-go wget

# Command line arguments for the go build

# Install FoundationDB client libraries
RUN wget && dpkg -i foundationdb-clients_5.2.5-1_amd64.deb && rm foundationdb-clients_5.2.5-1_amd64.deb

# Add example program
ADD src/main.go /go/src/main.go

CMD /bin/bash

The src/main.go file is just the example file from godoc with the apiversion 520 instead of 200. In reality our own codebase is there in the src directory.

Build this and start a container:

docker build -t test .
docker run -it -w /go/src/ test /bin/bash

Now try a go get, this results:

root@dd4d269335a2:/go/src# go get
# undefined: NetworkOptions

This doesn’t get solved when doing a checkout of the release-5.1 or any other branch as some issues are related to that (see github).

Additionally I can run using the go bindings on my Mac just fine, but when I try to compile for Linux directly on it (instead of in the Docker container) I get the same error.

(Alec Grieser) #4

Okay, I think I know what’s going on.

I left a more detailed response as a comment on a GitHub issue where you had raised this problem, but I think it’s a cgo configuration issue and that setting the CGO_ENABLED environment variable to 1 should fix the issue.