webp icon indicating copy to clipboard operation
webp copied to clipboard

Error for Linux Build

Open smalloff opened this issue 3 years ago • 8 comments

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\[email protected]\webp.go:22:9: undefined: webpGetInfo C:\Users\admin\go\pkg\mod\github.com\chai2010\[email protected]\webp.go:26:20: undefined: webpDecodeGray C:\Users\admin\go\pkg\mod\github.com\chai2010\[email protected]\webp.go:39:20: undefined: webpDecodeRGB C:\Users\admin\go\pkg\mod\github.com\chai2010\[email protected]\webp.go:52:20: undefined: webpDecodeRGBA C:\Users\admin\go\pkg\mod\github.com\chai2010\[email protected]\webp.go:68:14: undefined: webpDecodeGrayToSize C:\Users\admin\go\pkg\mod\github.com\chai2010\[email protected]\webp.go:82:14: undefined: webpDecodeRGBToSize C:\Users\admin\go\pkg\mod\github.com\chai2010\[email protected]\webp.go:96:14: undefined: webpDecodeRGBAToSize C:\Users\admin\go\pkg\mod\github.com\chai2010\[email protected]\webp.go:109:7: undefined: toGrayImage C:\Users\admin\go\pkg\mod\github.com\chai2010\[email protected]\webp.go:110:14: undefined: webpEncodeGray C:\Users\admin\go\pkg\mod\github.com\chai2010\[email protected]\webp.go:119:14: undefined: webpEncodeRGB C:\Users\admin\go\pkg\mod\github.com\chai2010\[email protected]\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!

smalloff avatar Jul 22 '22 14:07 smalloff

I have the same error on a docker build.

Pukka922 avatar Aug 10 '22 12:08 Pukka922

I have the same error on a docker build.

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

smalloff avatar Aug 10 '22 20:08 smalloff

@smalloff @Pukka922 try to add env CGO_ENABLED=1

michu91 avatar Aug 31 '22 11:08 michu91

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

ydylla avatar Mar 05 '23 22:03 ydylla

Same issue, maintainers helps us out here

aerosouund avatar Dec 15 '23 09:12 aerosouund