objectbox / objectbox-go

Embedded Go Database, the fast alternative to SQLite, gorm, etc.
https://objectbox.io
Apache License 2.0
1.1k stars 45 forks source link

Cgo compile error with gcc on Windows 10 Pro: " undefined reference to `obx_txn_mark_success" #39

Closed gcaplan closed 2 years ago

gcaplan commented 2 years ago

Hi

Trying to run the Task demo code from the getting started docs but compile is failing with the following error:

GOROOT=C:\Program Files\Go #gosetup
GOPATH=C:\Users\user\go #gosetup
"C:\Program Files\Go\bin\go.exe" build -o C:\Users\user\AppData\Local\Temp\GoLand\___go_build_scratch1_go.exe "D:\Google Drive\Golang\AlphaEngine\ae\scratch\scratch1\scratch1.go" #gosetup
# github.com/objectbox/objectbox-go/objectbox
c:/users/user/appdata/local/programs/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: $WORK\b002\_x012.o: in function `_cgo_1d5082261c69_Cfunc_obx_txn_mark_success':
/tmp/go-build/cgo-gcc-prolog:134: undefined reference to `obx_txn_mark_success'
collect2.exe: error: ld returned 1 exit status

Compilation finished with exit code 2

I'm not a low-level developer so please forgive if I'm making a newbie error.

Please advise!

greenrobot commented 2 years ago

Looks like a mismatch of C and Go versions: obx_txn_mark_success is obsolete and was removed from the C API in the latest version; you need to update to the latest Go version (1.6.0).

gcaplan commented 2 years ago

Thanks, but that doesn't seem to be the issue.

I was running Go 1.7.1.

I've update to the latest versions of Go and the MinGW compiler, but am still seeing the same error:

# github.com/objectbox/objectbox-go/objectbox
c:/users/user/appdata/local/programs/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: $WORK\b002\_x012.o: in function `_cgo_1d5082261c69_Cfunc_obx_txn_mark_success':
/tmp/go-build/cgo-gcc-prolog:134: undefined reference to `obx_txn_mark_success'
collect2.exe: error: ld returned 1 exit status
greenrobot commented 2 years ago

Looks like a mismatch of C and Go versions

Clarification: C and Go versions of ObjectBox

gcaplan commented 2 years ago

As someone with a rather shallow understanding of C compilers, how would I resolve this?

greenrobot-team commented 2 years ago

To update the ObjectBox Go package you probably need to run go get -u github.com/objectbox/objectbox-go/objectbox.

This assumes that you already ran the install script or did the manual steps from https://golang.objectbox.io/install#windows (which you indicated you did in the last issue).

gcaplan commented 2 years ago

Thanks - that solved the problem - I had installed ObjectBox before the new release last week, which appears to have been a breaking change?