1

I am new to GO and to objectbox. I am on Windows 10. My version of GO is

go version go1.20.1 windows/amd64

I am using Visual Studio 1.77.3

I am working through the demo at

https://golang.objectbox.io/getting-started

when I declared the import of

"github.com/objectbox/objectbox-go/objectbox"

the IDE downloaded the dependency for me.

I copy/paste the function initObjectBox as

func initObjectBox() *objectbox.ObjectBox {
    objectBox, err := objectbox.NewBuilder().Model(model.ObjectBoxModel()).Build()
    return objectBox
}

and when I am done, the IDE has underlines on objectbox.ObjectBox and objectbox.NewBuilder that says

undefined: objectbox.ObjectBox
undefined: objectbox.NewBuilder

The IDE knows about objectbox, when I shift-click the word objectbox it takes me to the import declaration in my code:

"github.com/objectbox/objectbox-go/objectbox"

When I shift-click that import it takes me to

/go/pkg/mod/github.com/objectbox/[email protected]

Thinking this must be my fault, I instead download the objectbox project

git clone https://github.com/objectbox/objectbox-go

when I open that I find

examples/tasks/main.go

which looks very much like the getting-started example. This code shows the same error for every single dot property of objectbox except objectBox.Close

undefined: objectbox.ObjectBox
undefined: objectbox.NewBuilder
undefined: objectbox.SyncIsAvailable
undefined: objectbox.SyncCredentialsNone
undefined: objectbox.SyncChange

When I try to run the app in GO I get the errors described in

https://github.com/objectbox/objectbox-go/issues/17

I have installed TDM-GCC-64 and I have run the install.ps1 script from https://golang.objectbox.io/install#windows which downloaded objectbox.dll to

C:\TDM-GCC-64\lib\objectbox.dll

The objectbox dll also got copied to my

C:\Windows\System32

I ran the tdm-gcc insaller at

https://github.com/jmeubank/tdm-gcc/releases/download/v10.3.0-tdm64-2/tdm64-gcc-10.3.0-2.exe

and my path contains

C:\TDM-GCC-64\bin

my GOPATH is

go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Dave\AppData\Local\go-build
set GOENV=C:\Users\Dave\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\Dave\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\Dave\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.20.1
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=C:\projects\gogo\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\Dave\AppData\Local\Temp\go-build1594667240=/tmp/go-build -gno-record-gcc-switches

1 Answer 1

0

As I was preparing all the information above to create the best possible question, I wondered if the windows path addition

C:\TDM-GCC-64\bin

was updated after I started Visual Studio. I shut down Visual Studio and re-started it and opened my example project and it ran perfectly. There are no errors in the IDE and the command line ran main.go without issue. I was using the Visual Studio console to run the command line, so even the command line issues were caused by this path problem. The error messages were very un-intuitive and not previously addressed in SO.

Sign up to request clarification or add additional context in comments.

1 Comment

trying this all from scratch on a new computer, ran into the same error, found this post, and the path was not the problem this time. even though there was a file C:\TDM-GCC-64\lib\objectbox.dll that was not what was on the path, the install script added C:\TDM-GCC-64\bin to the path. I dropped the dll into C:\Windows\System32 as I did before and it is running. The dll not being in the path is a bug in the objectbox install.ps1 script for setting up on Windows.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.