nguyenq / tess4j

Java JNA wrapper for Tesseract OCR API
Apache License 2.0
1.58k stars 372 forks source link

Tess4j not work on Mac M1 even with new JNA5.12.1 #245

Closed qwert321 closed 1 year ago

qwert321 commented 1 year ago

Error msg when running the tess4j: Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library 'tesseract': dlopen(/opt/homebrew/Cellar/tesseract/5.3.0_1/lib/libtesseract.dylib, 9): no suitable image found. Did find: /opt/homebrew/Cellar/tesseract/5.3.0_1/lib/libtesseract.dylib: mach-o, but wrong architecture


ENV: MacBookPro, Apple M1, macOS BigSur, version: 11.6.4


Tesseract Version: % brew info tesseract ==> tesseract: stable 5.3.0 (bottled), HEAD

and it works well on command line


file /opt/homebrew/Cellar/tesseract/5.3.0_1/lib/libtesseract.5.dylib /opt/homebrew/Cellar/tesseract/5.3.0_1/lib/libtesseract.5.dylib: Mach-O 64-bit dynamically linked shared library arm64


tess4j version:5.5.0, and jna version:5.12.1 % mvn dependency:tree ... ... [INFO] org.example:try:jar:1.0-SNAPSHOT [INFO] +- net.sourceforge.tess4j:tess4j:jar:5.5.0:compile [INFO] | +- net.java.dev.jna:jna:jar:5.12.1:compile


java code as your example: ITesseract instance = new Tesseract();
String result = instance.doOCR(imageFile);


Thoughts:

  1. the dynamic lib is right
  2. tess4j or jna think that they should not load arm64/M1 version dynamic lib, they are wrong. Because in fact, it's correct to load arm64/M1 version dynamic lib.
herou commented 5 months ago

@qwert321 how did you fix it?

miaozhiyan commented 5 months ago

@qwert321 how did you fix it?

how? i want ask me too