otiai10 / gosseract

Go package for OCR (Optical Character Recognition), by using Tesseract C++ library
https://pkg.go.dev/github.com/otiai10/gosseract
MIT License
2.74k stars 290 forks source link

library not found for -llept #302

Closed DZGodly closed 8 months ago

DZGodly commented 9 months ago

I encountered the same problem as in issue #248 , however the solutions mentioned in it don't work for me.

/usr/local/go/pkg/tool/darwin_amd64/link: running clang++ failed: exit status 1
ld: library not found for -llept
clang: error: linker command failed with exit code 1 (use -v to see invocation)

environment

d@ddeMacBook-Pro ~ % go version   
go version go1.19.3 darwin/amd64
d@ddeMacBook-Pro ~ % uname -a
Darwin ddeMacBook-Pro.local 22.3.0 Darwin Kernel Version 22.3.0: Mon Jan 30 20:42:11 PST 2023; root:xnu-8792.81.3~2/RELEASE_X86_64 x86_64
d@ddeMacBook-Pro ~ % uname -a   
Darwin ddeMacBook-Pro.local 22.3.0 Darwin Kernel Version 22.3.0: Mon Jan 30 20:42:11 PST 2023; root:xnu-8792.81.3~2/RELEASE_X86_64 x86_64
d@ddeMacBook-Pro ~ % go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/d/Library/Caches/go-build"
GOENV="/Users/d/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/d/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/d/go"
GOPRIVATE=""
GOPROXY="http://goproxy.bilibili.co"
GOROOT="/usr/local/go"
GOSUMDB="off"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.19.3"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/6z/pvnz4bnx13xcgcvvgm6f7h4w0000gp/T/go-build4120510851=/tmp/go-build -gno-record-gcc-switches -fno-common"
d@ddeMacBook-Pro ~ % go version
go version go1.19.3 darwin/amd64
d@ddeMacBook-Pro ~ % tesseract --version
tesseract 5.3.4
 leptonica-1.84.1
  libgif 5.2.1 : libjpeg 8d (libjpeg-turbo 3.0.0) : libpng 1.6.40 : libtiff 4.6.0 : zlib 1.2.11 : libwebp 1.3.2 : libopenjp2 2.5.0
 Found AVX512BW
 Found AVX512F
 Found AVX512VNNI
 Found AVX2
 Found AVX
 Found FMA
 Found SSE4.1
 Found libarchive 3.7.2 zlib/1.2.11 liblzma/5.4.4 bz2lib/1.0.8 liblz4/1.9.4 libzstd/1.5.5
 Found libcurl/7.86.0 SecureTransport (LibreSSL/3.3.6) zlib/1.2.11 nghttp2/1.47.0
otiai10 commented 9 months ago

gosseract version?

s0t0na commented 8 months ago

I have the same issue on masOS Sonoma. gosseract version 2.2.1

otiai10 commented 8 months ago

https://github.com/otiai10/gosseract/releases

edias commented 8 months ago

Installing github.com/otiai10/gosseract/v2, I got this error:

main.go:6:2: no required module provides package github.com/otiai10/gosseract; to add it:
go get github.com/otiai10/gosseract

After running go get github.com/otiai10/gosseract I have this on my go.mod

require (
    github.com/otiai10/gosseract v2.2.1+incompatible // indirect
    github.com/otiai10/gosseract/v2 v2.4.1 // indirect
)

Then running my project Im getting...

/usr/local/go/pkg/tool/darwin_arm64/link: running clang++ failed: exit status 1
ld: warning: ignoring duplicate libraries: '-llept', '-ltesseract'
ld: library 'lept' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Go Env

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/roger/Library/Caches/go-build'
GOENV='/Users/roger/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/roger/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/roger/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.0'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/roger/Workspace/app/ocr/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/yt/z5kdx8690gvbl67tmvc_4_2m0000gn/T/go-build3343530240=/tmp/go-build -gno-record-gcc-switches -fno-common'
tesseract --version
tesseract 5.3.4
 leptonica-1.84.1
  libgif 5.2.1 : libjpeg 8d (libjpeg-turbo 3.0.0) : libpng 1.6.43 : libtiff 4.6.0 : zlib 1.2.12 : libwebp 1.3.2 : libopenjp2 2.5.2
 Found NEON
 Found libarchive 3.7.2 zlib/1.2.12 liblzma/5.4.4 bz2lib/1.0.8 liblz4/1.9.4 libzstd/1.5.5
 Found libcurl/8.1.2 SecureTransport (LibreSSL/3.3.6) zlib/1.2.12 nghttp2/1.55.1
edias commented 8 months ago

It turned out I was importing the old library on my project

import (
    "github.com/otiai10/gosseract"
)

After changing to v2, everything compile fine.

import (
    "github.com/otiai10/gosseract/v2"
)