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

How to statically compile in golang so library is included? #47

Open shrinidhi111 opened 1 year ago

shrinidhi111 commented 1 year ago

Description

When deploying the binary, it also expects the library (.so file) available at system level

I tried keeping this file next to the binary but it did not work

Is there a way to statically compile in golang so one binary has all its dependencies?

What I tried

go build -ldflags="-extldflags=-static"

Error I got

/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: cannot find -lobjectbox: No such file or directory
/usr/bin/ld: /tmp/go-link-2309517836/000004.o: in function `_cgo_cbcce81e6342_C2func_getaddrinfo':
/tmp/go-build/cgo-gcc-prolog:58: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
collect2: error: ld returned 1 exit status