kolesa-team / go-webp

Simple and fast webp library for golang
MIT License
225 stars 36 forks source link

fatal error: 'webp/encode.h' file not found #11

Closed LainNetWork closed 2 years ago

LainNetWork commented 2 years ago

Hello,I'm using M1 MacBook Pro,MacOs Monterey.And I have installed webp package, but when I try to run this lib,I got this error:

# github.com/kolesa-team/go-webp/encoder
../../../go/pkg/mod/github.com/kolesa-team/go-webp@v1.0.1/encoder/encoder.go:27:10: fatal error: 'webp/encode.h' file not found
#include <webp/encode.h>
         ^~~~~~~~~~~~~~~
1 error generated.
# github.com/kolesa-team/go-webp/decoder
../../../go/pkg/mod/github.com/kolesa-team/go-webp@v1.0.1/decoder/decoder.go:27:10: fatal error: 'webp/decode.h' file not found
#include <webp/decode.h>
         ^~~~~~~~~~~~~~~
1 error generated.

I installed webp lib with brew, and I found header files in this path,but I don't know how to link it:

/opt/homebrew/include/webp

Some one says that new MacOS seemed to have stopped using /usr/local/include/. See this link I'm not proficient in cgo and C,I don't known how to change the path to let cgo link these header files.I try to google but got no answer.Can you help me to solve this problem?Thank you!

LainNetWork commented 2 years ago

Okey,I have solved this problem. Set env value like these: CGO_CFLAGS=-I/opt/homebrew/include CGO_LDFLAGS=-L/opt/homebrew/lib