Skip to content

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

Open
@shrinidhi111

Description

@shrinidhi111

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions