objectbox-go icon indicating copy to clipboard operation
objectbox-go copied to clipboard

How to statically compile in golang so library is included?

Open shrinidhi111 opened this issue 11 months ago • 0 comments

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

shrinidhi111 avatar Sep 12 '23 10:09 shrinidhi111