简体   繁体   中英

tess4j for linux UnsatisfiedLinkError

I am using tess4J api in order to deal with ocr process. I have successfully deployed my project on windows but i got stuck to run that project on linux ubunutu. According to my research i must have to use .so files instead of .dll files for linux. My simple code snippet looks like belove

import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;
import net.sourceforge.tess4j.util.PdfUtilities;

private static Tesseract instance;
    try {
            System.out.println(getPath());
            instance.setDatapath(getPath()+"/tessdata");
            result = instance.doOCR(file);
            System.out.println(result);
        } catch (Exception e) {
            logger.log(Level.INFO, e.getMessage(), e);
            throw new TesseractException(e);
        }

I have tessdata folder for linux os and put it into the classpath and have several .so file also put it into the folder into the classpath. eglinux-x86v folder.

my printstacktrace is as follows..

java.lang.UnsatisfiedLinkError: /tmp/tess4j.tmp/linux-x86/liblept.so: libjbig.so.0: cannot open shared object file: No such file or directory
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary1(ClassLoader.java:1965)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1890)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1851)
    at java.lang.Runtime.load0(Runtime.java:795)
    at java.lang.System.load(System.java:1062)
    at net.sourceforge.tess4j.util.LoadLibs.loadLibs(LoadLibs.java:127)
    at net.sourceforge.tess4j.util.LoadLibs.<init>(LoadLibs.java:71)
    at net.sourceforge.tess4j.util.LoadLibs.<clinit>(LoadLibs.java:38)
    at net.sourceforge.tess4j.TessAPI.<clinit>(TessAPI.java:40)
    at net.sourceforge.tess4j.Tesseract.init(Tesseract.java:286)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:222)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:171)
    at net.sourceforge.tess4j.Tesseract.doOCR(Tesseract.java:155)

please suggest any solution on how to run tess4j api on linux platform and what type of files do we require to run tess4j api either .so or .dll. that help would be appreciated.Thnk you.

I had the same issue. I solved it by downloading a compiled packages of necessary dependencies. In your case you should download Leptonica library, which would contain liblept.so . Be care in choice of version of library and compare it with version mentioned in tess4j dependency list.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM