chai2010 / webp

WebP decoder and encoder for Go (Zero Dependencies).
http://godoc.org/github.com/chai2010/webp
BSD 3-Clause "New" or "Revised" License
512 stars 89 forks source link

Error for Linux Build #48

Open smalloff opened 1 year ago

smalloff commented 1 year ago

Hi! My params for Linux release.

set GOARCH=amd64 set GOOS=linux go build -ldflags "-s -w"

Output:

C:\Users\admin\go\pkg\mod\github.com\chai2010\webp@v1.1.1\webp.go:22:9: undefined: webpGetInfo C:\Users\admin\go\pkg\mod\github.com\chai2010\webp@v1.1.1\webp.go:26:20: undefined: webpDecodeGray C:\Users\admin\go\pkg\mod\github.com\chai2010\webp@v1.1.1\webp.go:39:20: undefined: webpDecodeRGB C:\Users\admin\go\pkg\mod\github.com\chai2010\webp@v1.1.1\webp.go:52:20: undefined: webpDecodeRGBA C:\Users\admin\go\pkg\mod\github.com\chai2010\webp@v1.1.1\webp.go:68:14: undefined: webpDecodeGrayToSize C:\Users\admin\go\pkg\mod\github.com\chai2010\webp@v1.1.1\webp.go:82:14: undefined: webpDecodeRGBToSize C:\Users\admin\go\pkg\mod\github.com\chai2010\webp@v1.1.1\webp.go:96:14: undefined: webpDecodeRGBAToSize C:\Users\admin\go\pkg\mod\github.com\chai2010\webp@v1.1.1\webp.go:109:7: undefined: toGrayImage C:\Users\admin\go\pkg\mod\github.com\chai2010\webp@v1.1.1\webp.go:110:14: undefined: webpEncodeGray C:\Users\admin\go\pkg\mod\github.com\chai2010\webp@v1.1.1\webp.go:119:14: undefined: webpEncodeRGB C:\Users\admin\go\pkg\mod\github.com\chai2010\webp@v1.1.1\webp.go:119:14: too many errors

Installed TDM-GCC OS Windows 10. Golang version 1.18.4

How can I compile for Linux? When building for Windows, there are no errors. Thanks!

Pukka922 commented 1 year ago

I have the same error on a docker build.

smalloff commented 1 year ago

I have the same error on a docker build.

Try this library github.com/nickalie/go-webpbin

michu91 commented 1 year ago

@smalloff @Pukka922 try to add env CGO_ENABLED=1

ydylla commented 1 year ago

For me Zig worked great as compiler when cross compiling from Windows to Linux.
I used these env variables:

GOOS=linux
GOARCH=amd64
CGO_ENABLED=1
CC="zig cc -target x86_64-linux-musl"
CXX="zig c++ -target x86_64-linux-musl"

Inspired by this article: https://dev.to/kristoff/zig-makes-go-cross-compilation-just-work-29ho

aerosouund commented 7 months ago

Same issue, maintainers helps us out here