Unable to load library 'tesseract': libtesseract.so: cannot open shared object file: No such file or directory
Asked Answered
E

4

10

I've had tesseract and Tess4J running on my MBP for a while now. Today I started to migrate my app to the server and started installing everything on the server. Prior to running Tess4J in tomcat I tried to run a simple java program to make sure everything is fine and dandy. It's not...

  • I'm on a centOS 64bit server
  • I've installed tesseract and its working fine - tesseract myimage.jpg mytext produces data

However, running my simple class that useses Tess4j produces this error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'tesseract': libtesseract.so: cannot open shared object file: No such file or directory

What I've done so far

  • I've ran sudo ldconfig after installing tesseract
  • I've search for libtesseract.so and its found in /usr/local/lib/libtesseract.so

Folder on server contains these files:

myimge.png  
ghost4j-0.3.1.jar  
jai_imageio.jar  
jna.jar  
maslab.jar  
pngj.jar  
tess4j.jar  
TesseractExample.class  
TesseractExample.java

tesseract -v produces:

tesseract -v
tesseract 3.02.02
 leptonica-1.69
  libjpeg 6b : libpng 1.2.49 : libtiff 3.9.4 : zlib 1.2.3

Question

How can I make Tess4J aware that libtesseract.so does exist?enter code here

Edna answered 9/3, 2013 at 4:32 Comment(2)
how did you install tesseract? I followed the link you gave below and downloaded one with english data, but that doesn't seem to install tesseract, it seems like just data for english recognition.Vescuso
Try https://mcmap.net/q/1037118/-unable-to-load-library-39-tesseract-39-libtesseract-so-cannot-open-shared-object-file-no-such-file-or-directoryPrussianism
B
29

I had this problem too.

Did you run the following after installing tesseract:

sudo ldconfig

That fixed it for me.

Bran answered 19/4, 2015 at 7:11 Comment(2)
Good answer :-)Prussianism
ldconfig tells applications where they can find the linked libraries. That's why the above command can be needed after installing something new, e.g.: manpages.ubuntu.com/manpages/bionic/man8/ldconfig.8.htmlPlasma
C
8

You must set LD_LIBRARY_PATH environment variable to the path where libtesseract.so is.

export LD_LIBRARY_PATH=/usr/local/lib
Commination answered 6/8, 2015 at 2:51 Comment(1)
Thank you! After 8 hours I've found you!Reduplicative
L
6

It is necessary to define the variable jna.platform.library.path. For instance:

-Djna.platform.library.path=/usr/local/lib/

Lungki answered 22/4, 2013 at 11:15 Comment(0)
E
2

Maybe it is a 32 bit library .so installed.

Ewan answered 9/3, 2013 at 4:37 Comment(7)
I installed tesseract-ocr-3.02.eng.tar.gz from here code.google.com/p/tesseract-ocr/downloads/list and compiled it. if it installed a 32 bit library...is there a work around it?Edna
Try setting the path to the library like one of these: chilkatsoft.com/java-loadLibrary-Linux.aspEwan
hmm well that got rid of the libtesseract.so error but now I've got same error for these two /usr/local/lib/libtesseract.so.3.0.2: liblept.so.3: cannot open shared object file: and these aren't doing away by explicitply adding the path in code or adding them in the paths already in java.library.pathEdna
Do you have liblet.so or liblept.so.3? Make a symlink if one of these is not present.Ewan
hmm no. I don't have either one of those. What do I make a symblink link from ...since I don't have these two files present..Edna
The symlink was in case only one of them was not present. Maybe you'll need to install liblept.Ewan
I reinstalled leptonica and this time around ran sudo ldconfig so it created liblept.so.3 and placed it in /usr/local. I'm able to execute the class now just fine. Now into having it work on tomcat! Thanks for helpEdna

© 2022 - 2024 — McMap. All rights reserved.