chai2010 / webp

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

Strange compiler errors when CGO_ENABLED=0 #9

Closed EtienneBruines closed 9 years ago

EtienneBruines commented 9 years ago

I'm trying to compile my Go project to one static binary file, without linking to external libraries.

I am doing so by using this command:

CGO_ENABLED=0 go get -a -u -ldflags '-s'

This however produces the following errors:

# github.com/chai2010/webp
../github.com/chai2010/webp/reader.go:17: undefined: maxWebpHeaderSize
../github.com/chai2010/webp/webp.go:13: undefined: webpGetInfo
../github.com/chai2010/webp/webp.go:17: undefined: webpDecodeGray
../github.com/chai2010/webp/webp.go:30: undefined: webpDecodeRGB
../github.com/chai2010/webp/webp.go:39: undefined: webpDecodeRGBA
../github.com/chai2010/webp/webp.go:52: undefined: webpEncodeGray
../github.com/chai2010/webp/webp.go:57: undefined: webpEncodeRGB
../github.com/chai2010/webp/webp.go:61: undefined: webpEncodeRGBA
../github.com/chai2010/webp/webp.go:65: undefined: webpEncodeLosslessGray
../github.com/chai2010/webp/webp.go:70: undefined: webpEncodeLosslessRGB
../github.com/chai2010/webp/webp.go:70: too many errors

Which is strange, because (for instance) maxWebpHeaderSize is declared in capi.go

Extra info:

OS: Debian Jessie
Kernel 3.2.0-4-amd64
go version go1.3.2 linux/amd64

Any thoughts?

Thanks in advance.

chai2010 commented 9 years ago

@EtienneBruines The current webp is based on cgo. If cgo is disabled, it will cause error. I will merge a puro go version to fix this issue when cgo is disabled.

thanks for your feedback.

chai2010 commented 9 years ago

@EtienneBruines

https://github.com/chai2010/webp/commit/e5bfb994b5ca7a67f64aa3ba0f7c66d154b03faa

Fix the build error if cgo is disabled. But the go test will fail.

I will close this issue.

PS: Just for webp, cgo use static link, output is one static binary file.

EtienneBruines commented 9 years ago

@chai2010 Perfect! Thank you for the rapid response. Good to know that I shouldn't use CGO_ENABLED=0 and webp together.

lizhecao commented 1 month ago

@EtienneBruines

e5bfb99

Fix the build error if cgo is disabled. But the go test will fail.

I will close this issue.

PS: Just for webp, cgo use static link, output is one static binary file.

how about the go test

jphastings commented 4 weeks ago

In case anyone else stumbles upon this; I had the same issue when I tried compiling this package on Alpine linux. The outcome is the same as CGO_ENABLED=0 disables CGo (which this package needs), and Alpine linux is based on an incompatible C library (I used an ubuntu-based docker image instead)