GithubHelp home page GithubHelp logo

undefined: fitz.New about go-fitz HOT 3 CLOSED

MichaelCharles avatar MichaelCharles commented on August 15, 2024
undefined: fitz.New

from go-fitz.

Comments (3)

gen2brain avatar gen2brain commented on August 15, 2024 1

You could also use e.g. zig, something like this CGO_ENABLED=1 CC="zig cc -target x86_64-windows-gnu" GOOS=windows, or maybe with clang, i.e. CC="clang --target=x86_64-pc-freebsd" CGO_ENABLED=1 GOOS=freebsd. In go-fitz case, there are no additional libraries that you need to have, all it needs is to link precompiled static library.

from go-fitz.

gen2brain avatar gen2brain commented on August 15, 2024

You are trying to cross-compile the CGO project. Of course, you cannot just change GOOS and be done. When you cross-compile, the Go will disable CGO, i.e. it will set CGO_ENABLED=0, so enable it, i.e. GOOS=linux CGO_ENABLED=1. Then you will see real errors, i.e. you are missing the correct C toolchain.

from go-fitz.

MichaelCharles avatar MichaelCharles commented on August 15, 2024

Thanks, I made further progress on this since I last commented. My problem has nothing to do with Fitz itself, but as you said, cross compiling. I'd like to post what I ended up doing here in case it ever turns up in someone's Google search results.

I figured the easiest way to get around this would be to build from inside of a Docker container. So I made a Dockerfile like so,

FROM golang:1.21.6

RUN apt-get update

RUN apt-get install -y gcc-x86-64-linux-gnu

ENV CGO_ENABLED=1
ENV CC=x86_64-linux-gnu-gcc

Which includes gcc-x86-64-linux-gnu as a cross compiler, and then built the dockerfile into an image:

docker build -t gobuild:latest .

From there, I used the new image to build my project:

docker run --rm -v "$(CURDIR)":/usr/src/myapp -w /usr/src/myapp gobuild:latest bash -c "export GO111MODULE=on && env GOARCH=amd64 go build  -ldflags=\"-s -w\" -o bin/thumbnail cmd/thumbnail/main.go"

And that let me build without errors! I'm running into a further problem there with my serverless function hanging on invocation, but that is likely an entirely unrelated issue.

from go-fitz.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.