Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
488 views
in Technique[技术] by (71.8m points)

java - Tess4j unsatisfied link error on mac OS X

Hey i am trying to use tess4j for tesseract and having this issue for eclipse on mac osx .

My tesseract is working fine from terminal but trying to run tess4j through tesseract throws me an error .

java.lang.UnsatisfiedLinkError: Unable to load library 'tesseract': Native library (darwin/libtesseract.dylib)

i do have tessetact dylib and its named libtesseract.dylib in my opt/local/lib which i installed using macport .

Thanks for your help

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I know it's an old post. I had this problem too recently when I tried to use Tess4J. However, I managed to find a way around it. I've written a post about it http://www.microshell.com/programming/java/performing-optical-character-recognition-in-java/

In short, the problem is because tess4j-2.0.0.jar doesn't include MacOS library. So I just modified the maven cached jar on mine by doing these steps:

  1. cd /Users/user/.m2/repository/net/sourceforge/tess4j/tess4j/2.0.0 (adjust the directory where your tess4j JAR file resides)
  2. mkdir darwin
  3. jar uf tess4j-2.0.0.jar darwin
  4. cp /opt/local/lib/libtesseract.3.dylib darwin/libtesseract.dylib
  5. jar uf tess4j-2.0.0.jar darwin/libtesseract.dylib
  6. jar tf tess4j-2.0.0.jar (to verify that the file is included)

I was then able to run my Java program after I modify the tess4j-2.0.0.jar file. Below is my MacOS version.

user@laptop:~$ uname -a
Darwin Maresas-MacBook-Pro.local 14.3.0 Darwin Kernel Version 14.3.0: Mon Mar 23 11:59:05 PDT 2015; root:xnu-2782.20.48~5/RELEASE_X86_64 x86_64

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...