0

I am creating an OCR application in java using tess4j and this works on my windows machine. However, when migrating over to the raspbian machine that the application will be running on i got the error “Unable to load library 'tesseract': libtesseract.so” as its not found in the jars resource path.

I found this question relating to the same problem and saw it could be solved by using "sudo apt-get install tesseract-ocr" however when i tried this instead of solving the issue it causes the JVM machine to SIGSEGV and crash. Is there any other way i can solve this problem and obtain the libtesseract.so file?

Sean Powell
  • 564
  • 4
  • 20
  • Please provide some details about the Raspberry machine (3 or 4, how much memory, 32 or 64 bit, …) and the installed Raspbian (version etc.) – tquadrat Mar 23 '20 at 23:22
  • @tquadrat Its a Raspberry PI version 3 Model B (1GB of RAM and 64 bit CPU) and the install Raspbian version is version 10. The version of Java is also 11.0.6 – Sean Powell Mar 23 '20 at 23:27
  • You have seen this link, too? -> https://stackoverflow.com/questions/15307168/unable-to-load-library-tesseract-libtesseract-so-cannot-open-shared-object-f – tquadrat Mar 24 '20 at 06:31
  • @tquadrat i have tried the solution of setting the eviroment variable and it did not solve the issue. It is still causing the same issue – Sean Powell Mar 24 '20 at 11:17
  • If I should guess, I would say that the JVM finds a libtesseract.so, but that this is somehow invalid (it is for another architecture than the JVM - 32 vs. 64 bit, or another processor architecture in general, or the binary was damaged on download, or it is an old version that does not work with the current kernel, or …). That in turn causes the SIGSEGV … Search for all occurrences of that file on your system, and compare them. Make sure that there is just one remaining, and that LD_LIBRARY_PATH is pointing to its location. – tquadrat Mar 24 '20 at 11:30
  • BTW: the Raspi has a 64-bit architecture, but are you running the OS in 64-bit mode? – tquadrat Mar 24 '20 at 11:31
  • @tquadrat i just checked and uname-m returns aarch64 so it appears i am running a 64 bit OS – Sean Powell Mar 24 '20 at 11:34
  • And which JVM did you install? Which version of Tesseract? – tquadrat Mar 24 '20 at 12:27
  • @tquadrat the version of JVM is 11.0.6 and the version of tesseract is 4.5.1 – Sean Powell Mar 24 '20 at 12:43
  • Yes, you wrote that earlier! And what about the bits? 32 or 64?? – tquadrat Mar 24 '20 at 18:48
  • @tquadrat seems i am using a 32 bit version of Java due to another libarys requirements – Sean Powell Mar 25 '20 at 10:18
  • Ok, 32bit JVM - and what is about the `libtesseract.so`? 32bit or 64bit? Mixing that is possible if both sides are prepared properly – if not, it may cause what you see … – tquadrat Mar 25 '20 at 13:01
  • @tquadrat thanks for your help i fixed it by building leptonica from source instead of the apt-get. Thanks once again tho – Sean Powell Mar 25 '20 at 13:32

1 Answers1

2

I manged to fix this by having to compile both Leptonica and Tesseract from source.

Sean Powell
  • 564
  • 4
  • 20