lxc / go-lxc

Go bindings for liblxc
https://linuxcontainers.org/lxc
Other
428 stars 77 forks source link

Build failed when specify ldflags -static #159

Closed kwanhur closed 2 years ago

kwanhur commented 2 years ago

Installed lxc-libs lxc-devel on CentOS7, couldn't find any static link infos with pkg-config --static lxc

go build errors:

GOOS=linux GOARCH=amd64 GO111MODULE=on go build -v -ldflags "--extldflags=-static" lxc.go
# command-line-argusments
/usr/lib/golang/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: cannot find -llxc

relate versions:

stgraber commented 2 years ago

That'd be an issue with your distribution, if they don't ship the .a/.la files needed for static compilation, then downstream users like go-lxc can't find them.

Not that I'd actually ever recommend statically building liblxc, it's completely untested and quite scary from a security point of view.