Mac OS run err:ld: library not found for -lleptonica
hktalent opened this issue · 3 comments
hktalent commented
$ go version
go version go1.20.7 darwin/amd64
$ brew install tesseract
Warning: tesseract 5.3.2 is already installed and up-to-date.
To reinstall 5.3.2, run:
brew reinstall tesseract
$ brew install leptonica
Warning: leptonica 1.82.0_2 is already installed and up-to-date.
To reinstall 1.82.0_2, run:
brew reinstall leptonica
$ brew --prefix leptonica
/usr/local/opt/leptonica
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/opt/tesseract/lib:/usr/local/opt/leptonica:/usr/local/lib
(base) 51pwn@51pwn-2 zlmv $ go build -o ocrImg -ldflags=" -L/usr/local/opt/leptonica/lib -lleptonica" Main.go
# command-line-arguments
flag provided but not defined: -L/usr/local/opt/leptonica/lib
usage: link [options] main.o
$ c++
clang: error: no input files
$ c++ -v
Apple clang version 15.0.0 (clang-1500.0.40.1)
Target: x86_64-apple-darwin23.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
goland debug
# github.com/hktalent/CCAK/test/zlmv
/usr/local/opt/go/libexec/pkg/tool/darwin_amd64/link: running c++ failed: exit status 1
ld: library not found for -lleptonica
clang: error: linker command failed with exit code 1 (use -v to see invocation)
hktalent commented
macOS not
gosseract/preprocessflags_x.go
Line 4 in ee227ad
// #cgo CXXFLAGS: -std=c++0x
// #cgo CPPFLAGS: -I/usr/local/include
// #cgo CPPFLAGS: -Wno-unused-result
// #cgo LDFLAGS: -L/usr/local/lib -lleptonica -ltesseract
n1architect commented
Same issue here. Were you able to fix it?
hktalent commented
@andyrodionov @otiai10
macos:
1. In the terminal, enter the following command to install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
2. Install the Leptonica library:
brew install leptonica
3. Verify whether the Leptonica library has been installed successfully:
brew list leptonica
sudo ln -s /usr/local/Cellar/leptonica/1.83.1 /usr/local/opt/leptonica
sudo ln -s /usr/local/opt/leptonica/lib/libleptonica.6.dylib /usr/local/opt/leptonica/lib/liblept.5.dylib
4. Check dependencies
otool -L /usr/local/opt/leptonica/lib/libleptonica.6.dylib
5. Which third-party libraries does gossipact depend on?
Tesseract: an open source OCR engine
Leptonica: an image processing library for processing and analyzing images
Jpeg: an image codec library for processing JPEG images
Gzip: a data compression library for compressing and decompressing data
Curl: a network library for accessing network resources
gosseract uses pkg-config to obtain dependencies of third-party libraries. When compiling gosseract, these third-party libraries need to be installed.
Here is a detailed description of gosseract dependencies:
Tesseract: gossiper uses Tesseract for OCR recognition. Tesseract is an open source OCR engine that supports multiple languages and fonts.
Leptonica: gossipact uses Leptonica to process and analyze images. Leptonica is an image processing library that supports multiple image formats.
Jpeg: gossiperact uses Jpeg to process JPEG images. Jpeg is an image codec library that supports the JPEG image format.
Gzip: gossipact uses Gzip to compress and decompress data. Gzip is a data compression library that supports the Gzip compression format.
Curl: gossipact uses Curl to access network resources. Curl is a network library that supports protocols such as HTTP and HTTPS.
In macOS, you can use the following command to install the third-party libraries that gosseract depends on:
brew install tesseract leptonica jpeg gzip curl
In Linux, you can use the following command to install the third-party libraries that gosseract depends on:
sudo apt install tesseract-ocr libleptonica-dev libjpeg-dev zlib1g-dev libcurl4-openssl-dev