davidbyttow / govips

A lightning fast image processing and resizing library for Go
MIT License
1.23k stars 196 forks source link

support fully static link build #394

Open cruvie opened 8 months ago

cruvie commented 8 months ago

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
the-hotmann commented 7 months ago

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.

andrask commented 7 months ago

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.