gen2brain / go-fitz

Golang wrapper for the MuPDF Fitz library
GNU Affero General Public License v3.0
412 stars 96 forks source link

Go build error: undefined: fitz.New #74

Closed JensvandeWiel closed 1 year ago

JensvandeWiel commented 1 year ago

Does not matter what i use: NewFromReader, NewFromMemory or New it throws the same error

JensvandeWiel commented 1 year ago

it is inported and added to go.mod

gen2brain commented 1 year ago

This looks like a basic Go question, I cannot reproduce your problem, sorry.

JensvandeWiel commented 1 year ago

i've tried everything but i can not get it to work. ill try to reproduce it on another machine

JensvandeWiel commented 1 year ago

its something in the enviroment

JensvandeWiel commented 1 year ago

dont know what yet

ivanmartos commented 1 year ago

I'm having same issue go mod


go 1.20

require (
    github.com/gen2brain/go-fitz v1.20.2
)

I'm receiving compile time errors

internal/dataMatrixParser/services.go:16:58: undefined: fitz.Document

Code snippet

package XXX

import (
"bytes"
"github.com/gen2brain/go-fitz"
"github.com/XXX/XXXXX/internal/model"
"image"
)

type MatrixParser interface {
    ParsePdf(parsingRequest model.ParsingRequest, doc *fitz.Document) (*bytes.Buffer, error)
}
}

When I was using version v0.0.0-20201207194431-072519bd9a7e I had no problems

15365917109 commented 1 year ago

我也遇到同意的问题 请问你解决了吗

gen2brain commented 1 year ago

I guess you all are using Windows. The most simple way to install the GCC compiler for me on Windows was to use TDM-GCC. There is also mingw64, you need to install the compiler for the arch you are going to use. I guess if anyone just enabled verbose build everything should be clear. Anyway, this is not the right place for such questions.

dyhgoa commented 9 months ago

Error undefined: fitz.NewFromMemory : Fitz in cross compiling Linux under Windows 10

gen2brain commented 9 months ago

@dyhgoa When you cross-compile, Go will set CGO_ENABLED to 0, when you set it to 1, you will see the real error message, i.e. you want to compile for Linux with C compiler for Windows, etc. Of course, you cannot just change GOOS and expect it to work.