Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined问题 #71

Open
homeeecode3 opened this issue Jun 20, 2024 · 4 comments
Open

undefined问题 #71

homeeecode3 opened this issue Jun 20, 2024 · 4 comments

Comments

@homeeecode3
Copy link

按照文档的方式写了示例代码:
package main

import (
"bytes"
"fmt"
"io/ioutil"
"log"

"github.com/chai2010/webp"

)

func main() {
var buf bytes.Buffer
var width, height int
var data []byte
var err error

// Load file data
if data, err = ioutil.ReadFile("./testdata/1_webp_ll.webp"); err != nil {
	log.Println(err)
}

// GetInfo
if width, height, _, err = webp.GetInfo(data); err != nil {
	log.Println(err)
}
fmt.Printf("width = %d, height = %d\n", width, height)

// GetMetadata
if metadata, err := webp.GetMetadata(data, "ICCP"); err != nil {
	fmt.Printf("Metadata: err = %v\n", err)
} else {
	fmt.Printf("Metadata: %s\n", string(metadata))
}

// Decode webp
m, err := webp.Decode(bytes.NewReader(data))
if err != nil {
	log.Println(err)
}

// Encode lossless webp
if err = webp.Encode(&buf, m, &webp.Options{Lossless: true}); err != nil {
	log.Println(err)
}
if err = ioutil.WriteFile("output.webp", buf.Bytes(), 0666); err != nil {
	log.Println(err)
}

fmt.Println("Save output.webp ok")

}

go.mod中:
module test_prj

go 1.20

require (
github.com/chai2010/webp v1.1.1
)

go run 的时候报错:

github.com/chai2010/webp

/root/go/pkg/mod/github.com/chai2010/[email protected]/webp.go:22:9: undefined: webpGetInfo
/root/go/pkg/mod/github.com/chai2010/[email protected]/webp.go:26:20: undefined: webpDecodeGray
/root/go/pkg/mod/github.com/chai2010/[email protected]/webp.go:39:20: undefined: webpDecodeRGB
/root/go/pkg/mod/github.com/chai2010/[email protected]/webp.go:52:20: undefined: webpDecodeRGBA
/root/go/pkg/mod/github.com/chai2010/[email protected]/webp.go:68:14: undefined: webpDecodeGrayToSize
/root/go/pkg/mod/github.com/chai2010/[email protected]/webp.go:82:14: undefined: webpDecodeRGBToSize
/root/go/pkg/mod/github.com/chai2010/[email protected]/webp.go:96:14: undefined: webpDecodeRGBAToSize
/root/go/pkg/mod/github.com/chai2010/[email protected]/webp.go:109:7: undefined: toGrayImage
/root/go/pkg/mod/github.com/chai2010/[email protected]/webp.go:110:14: undefined: webpEncodeGray
/root/go/pkg/mod/github.com/chai2010/[email protected]/webp.go:119:14: undefined: webpEncodeRGB
/root/go/pkg/mod/github.com/chai2010/[email protected]/webp.go:119:14: too many errors

golang版本:
go version go1.20.14 linux/amd64

@peach-zhang
Copy link

我也出现了

@misskey
Copy link

misskey commented Jul 19, 2024

这个问题请问下解决了吗 我也遇到了

@zyb-992
Copy link

zyb-992 commented Aug 20, 2024

这个问题请问下解决了吗 我也遇到了

我也出现了

CGO的环境变量被禁止了吧 go env -w CGO_ENABLED=1

@Allan-Nava
Copy link

it works CGO_ENABLED=1 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants