Open isrealbm opened 5 months ago
This works for me
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o out .
Hi,
I'm pretty sure @isrealbm is trying to run this on Asahi Linux on a Macbook with ARM, looking at the GOARCH value (correct me if I'm wrong). Edit: It says Darwin, which I think means Mac OS. Sorry for the mistake.
I can reproduce the issue myself, but I'm not sure if this is related to this library or due to the missing packages on Asahi Linux. Which exact packages are needed for Fedora?
I have the following installed on Ubuntu 24.04 and the library is working great:
libtesseract-dev/noble,now 5.4.1-1ppa1~noble1 amd64 [installed]
libtesseract5/noble,now 5.4.1-1ppa1~noble1 amd64 [installed]
tesseract-ocr-eng/noble,noble,now 1:4.1.0-2 all [installed,automatic]
tesseract-ocr-osd/noble,noble,now 1:4.1.0-2 all [installed,automatic]
tesseract-ocr/noble,now 5.4.1-1ppa1~noble1 amd64 [installed]
On Asahi Linux I have installed the following packages which leads to the error mentioned in the issue:
tesseract.aarch64
tesseract-devel.aarch64
tesseract-langpack-eng.noarch
tesseract-tessdata-doc.noarch
Still I don't have an env to test for Asahi Linux, though, for Fedora, this is the working answer https://github.com/otiai10/gosseract/blob/main/test/runtimes/fedora.Dockerfile
For Asahi, I'll work on it https://github.com/AsahiLinux/asahi-installer
@ayanel-ci test
Could you try and build within a podman-machine Linux VM?
It appears as though this is an attempt to build for Linux on macOS
Hello guys, sorry for a busy week. Yes, I have tried to build an application on the ARM64 chip (Apple silicon) to deploy to a VM running with AMD64 CPU. I think the problem happened by this library itself. I tried to install Tesseract directly in that VM and use other lib then everything was work as expected.
Hi,
I'm pretty sure @isrealbm is trying to run this on Asahi Linux on a Macbook with ARM, looking at the GOARCH value (correct me if I'm wrong). Edit: It says Darwin, which I think means Mac OS. Sorry for the mistake.
I can reproduce the issue myself, but I'm not sure if this is related to this library or due to the missing packages on Asahi Linux. Which exact packages are needed for Fedora?
I have the following installed on Ubuntu 24.04 and the library is working great:
libtesseract-dev/noble,now 5.4.1-1ppa1~noble1 amd64 [installed] libtesseract5/noble,now 5.4.1-1ppa1~noble1 amd64 [installed] tesseract-ocr-eng/noble,noble,now 1:4.1.0-2 all [installed,automatic] tesseract-ocr-osd/noble,noble,now 1:4.1.0-2 all [installed,automatic] tesseract-ocr/noble,now 5.4.1-1ppa1~noble1 amd64 [installed]
On Asahi Linux I have installed the following packages which leads to the error mentioned in the issue:
tesseract.aarch64 tesseract-devel.aarch64 tesseract-langpack-eng.noarch tesseract-tessdata-doc.noarch
Hey there! I actually have the similar issue where i cannot compile my project with CGO_ENABLED=0
. I am on nix-os linux (amd64).
Just to be clear, the projects works completely fine without the above flag but I need to make a statically linked application which is currently not possible due to gosseract giving this error.
I have also testing this with ubuntu:24.04 and alpine base image in docker and both gave the same result.
FROM alpine:latest
RUN apk add --no-cache \
go \
tesseract-ocr \
tesseract-ocr-dev \
leptonica-dev \
g++ \
tesseract-ocr-data-eng \
ffmpeg \
&& rm -rf /var/cache/apk/*
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY . .
RUN GOOS=linux GOARCH=amd64 go build -o /bin/subtle/subtle ./cmd/subtle
WORKDIR /media
CMD ["/bin/subtle/subtle"]
FROM alpine:latest
RUN apk add --no-cache \
go \
tesseract-ocr \
tesseract-ocr-dev \
leptonica-dev \
g++ \
tesseract-ocr-data-eng \
ffmpeg \
&& rm -rf /var/cache/apk/*
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download && go mod verify
COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /bin/subtle/subtle ./cmd/subtle
WORKDIR /media
CMD ["/bin/subtle/subtle"]
undefined: gosseract.Client
undefined: gosseract.NewClient
The above error is made during the building of the application with go build
and not a runtime error.
Please let me know if there are any more information you would need.
I have made an error in my previous comment which should be clarified.
Library like gosseract which uses native C code requires CGO to be enabled; so you cannot set CGO_ENABLED=0
.
The reason I tried disabling CGO is to statically build my go project. After some digging around it turns out you have to statically build both tesseract and leptonica in order to link them properly. I have made a PR showcasing the same.
Summary
go build failed:
undefined: gosseract.NewClient
when CGO_ENABLED=0If I change CGO_ENABLED to CGO_ENABLED=1 then will get other errors:
Reproducibility
Reproducibility Frequency
Environment