Skip to content

ld: library 'leptonica' not found #306

@filiprejmus

Description

@filiprejmus

Summary

I tried installing gosseract for my project and getting

/usr/local/go/pkg/tool/darwin_arm64/link: running clang++ failed: exit status 1
ld: library 'leptonica' not found
clang++: error: linker command failed with exit code 1

Code sample

client := gosseract.NewClient()
defer client.Close()
bodyBytes, err := io.ReadAll("IMAGE_BYTES")
if err != nil {
	return "", fmt.Errorf("unable to read file content: %v", err)
}
client.SetImageFromBytes(bodyBytes)
body, err = client.Text()
if err != nil {
	return "", fmt.Errorf("unable to convert file: %v", err)
}

Environment

uname -a
Darwin MacBook-Pro-von-Filip.local 23.4.0 Darwin Kernel Version 23.4.0: Wed Feb 21 21:44:06 PST 2024; root:xnu-10063.101.15~2/RELEASE_ARM64_T8103 arm64
go env
GO111MODULE='on'
GOARCH='arm64'
GOBIN='/Users/filiprejmus/go/bin'
GOCACHE='/Users/filiprejmus/Library/Caches/go-build'
GOENV='/Users/filiprejmus/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/filiprejmus/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/filiprejmus/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.1'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/filiprejmus/repos/the-platform/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/tx/nflzyw31689gryfy6_m7_z4r0000gn/T/go-build916142092=/tmp/go-build -gno-record-gcc-switches -fno-common'
go version
go version go1.22.1 darwin/arm64
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.11 liblzma/5.4.4 bz2lib/1.0.8 liblz4/1.9.4 libzstd/1.5.5
 Found libcurl/8.4.0 SecureTransport (LibreSSL/3.3.6) zlib/1.2.12 nghttp2/1.58.0

Bonus

I tried

export LIBRARY_PATH="/opt/homebrew/lib" 
export CPATH="/opt/homebrew/include" 

this makes my project compile but the process is killed right after running it

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions