govips icon indicating copy to clipboard operation
govips copied to clipboard

support fully static link build

Open cruvie opened this issue 1 year ago • 2 comments

It would be useful to build with fully static link, is there any way I can do to achive it? I tried the following cmd, but get some errors.

 CGO_ENABLED=0 go build -a -ldflags '-extldflags "-static"' .
/Users/cxxxxxtool.go:31:13: undefined: vips.NewAvifExportParams
/Users/cxxxxxtool.go:61:13: undefined: vips.NewJpegExportParams
/Users/cxxxxxtool.go:83:74: undefined: vips.ImageRef
/Users/cxxxxxtool.go:93:26: undefined: vips.NewImageFromReader
/Users/cxxxxxtool.go:108:82: undefined: vips.ImageRef
/Users/cxxxxxtool.go:119:39: undefined: vips.KernelAuto

cruvie avatar Dec 12 '23 16:12 cruvie

Duplicate: https://github.com/davidbyttow/govips/issues/339

But the problem remains - it seems this is not statically buildable. This is a pitty as a lot of golang users really want to compile it down to one single statically binary to place it into a docker scratch container for additional security and less overhead.

the-hotmann avatar Jan 06 '24 14:01 the-hotmann

I may be mistaken, but one of the reasons for dynlinking is the licence. Libvips is LGPL, while this package is MIT. With static linking, all software that uses this package would automatically turn into LGPL software. There are probably technical reasons, too. But as I can see, libvips language bindings are usually MIT or similar licenced.

andrask avatar Jan 18 '24 05:01 andrask