Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

liblept.so.4: cannot open shared object file #28

Closed
lukiant-dev opened this issue Jan 20, 2016 · 8 comments
Closed

liblept.so.4: cannot open shared object file #28

lukiant-dev opened this issue Jan 20, 2016 · 8 comments

Comments

@lukiant-dev
Copy link

Hello!
Unfortunately I am not able to run tesseract through tess4j on Linux (CentOS).
I think that tesseract is being loaded correctly with JNA, but for some reason he can't find liblept.so.
Is it possible to somehow tell tesseract which is loaded through JNA where he should look for liblept.so?
Or maybe it would be possible to compile tesseract in such way that leptonica shared library wouldn't be needed at execution time?

NOTE1: I can't set LD_LIBRARY_PATH environment variable. It solves the problem but cannot be done on my system.
NOTE2: Leptonica is not installed on local machine.
NOTE3: I have compiled Tesseract from the source (tried github master branch and 3.02 from sourceforge).

@4F2E4A2E
Copy link
Collaborator

Hi there!

Which version of tess4j and centos are you using?

Am 20.01.2016 um 19:53 schrieb lukiant-dev notifications@github.com:

Hello!
Unfortunately I am not able to run tesseract through tess4j on Linux (CentOS).
I think that tesseract is being loaded correctly with JNA, but for some reason he can't find liblept.so.
Is it possible to somehow tell tesseract which is loaded through JNA where he should look for liblept.so?
Or maybe it would be possible to compile tesseract in such way that leptonica shared library wouldn't be needed at execution time?

NOTE1: I can't set LD_LIBRARY_PATH environment variable. It solves the problem but cannot be done on my system.
NOTE2: Leptonica is not installed on local machine.
NOTE3: I have compiled Tesseract from the source (tried github master branch and 3.02 from sourceforge).


Reply to this email directly or view it on GitHub.

@lukiant-dev
Copy link
Author

tess4j src from master branch
CentOS 6.7 x64

@guggi1
Copy link

guggi1 commented Jan 21, 2016

Hi, I am having the same issue.

Using Tess4j-2.0.1.jar which comes with Tesseract 3.03 and Leptonica 1.7.

It works fine on Tomcat under Windows but Linux won't work.
I have compiled Tesseract and Leptonica on my Linux Servers and taken the libtesseract.so file and it recognizes it. So far so good. However the liblept.so.4 is not recognized anywhere.
I have tried the following:

  1. gave full permission (chmod 777 liblept.so.4)
  2. placed the liblept.so.4 under user/local
  3. placed the liblept.so.4 under user/local/share
  4. added the liplept.so.4 to the tess4j JAR (together with libtesseract.so) under /linux-x86-64
  5. placed the liblept.so.4 under TOMCAT_HOME/lib and set the path in the wrapper of tomcat.config
    (wrapper.java.additional.4=-Djna.library.path=%TOMCAT_HOME%/lib)
  6. tried to work with LD_LIBRARY_PATH
  7. Placed it under WEB-INF/classes

Always the same error:
UnsatisfiedLinkError: liblept.so.4: cannot open shared object file: No such file or directory

@ghost
Copy link

ghost commented Jan 21, 2016

Had the same problem, solved it for me by loading liblept.so in the static-block in LoadLibs. So leptonica.so is loaded before tesseract is loaded by calling getTessAPIInstance.

@guggi1
Copy link

guggi1 commented Jan 21, 2016

Very smart approach. I will try it. Did you use the static function?
System.loadLibrary("liblept");

@ghost
Copy link

ghost commented Jan 21, 2016

Yes, I packed liblept.so.4 with tess4j, extracted it to the tempdir like tess4j does with tesseract and called
System.load(targetTempFolder + "/liblept.so.4");

@guggi1
Copy link

guggi1 commented Jan 21, 2016

People, mhinters rules! Thanks. It worked.

Please note:

  1. Using System.loadLibrary("liblept") did not work although the file was present in the java.library.path (Tesseract tries to load from a different place)
  2. We have also tried renaming "liblept.so.4" to "liblept.so" which did not work

The only thing was to give the real full path of "liblept.so.4" to the static function and calling it before Tesseract does, like this:

System.load("/opt/tomcat7/project/liblept.so.4") ;

mhinters, thanks again.

PS: Make sure the file has the right permissions

@4F2E4A2E
Copy link
Collaborator

You can also create a symlink.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants