Search code examples
c#linuxasp.net-coretesseract

Error Could not load file or assembly Tesseract on Ubuntu using .Net Core 3.1


I am using Tesseract version 4.1.1 on dotnetcore 3.1 project which works perfectly on windows but when I publish it on ubuntu it throws the following error on this line

new TesseractEngine(Tessdatapath, LanguageCode, EngineMode.TesseractAndLstm);

Could not load file or assembly 'Tesseract, Version=4.1.1.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

I copied the x64 & x86 dlls with the publish files and made sure they are on the same level with tessdata

I tried to install tesseract on ubuntu and copied the .so files inside the x64 & x86 folders but still no luck


Solution

  • So here is how I fixed it

    It turned out that system didnt display the correct error message because it couldnt use the library System.Drawing.Common which is not supported by Linux.

    Fixed that by using libgdiplux the Linux implementation of System.Drawing.Common

    sudo apt-get -f install libgdiplus
    

    Then it displayed the correct message which is

    Failed to find library "libleptonica-1.80.0.so" for platform x64.
    

    To fix that I had to compile this leptonica version from here http://www.leptonica.org/download.html

    this helped me to compile it http://www.leptonica.org/source/README.html

    So now that I have "libleptonica-1.80.0.so" installed I created link inside my x64 folder to leptonica files following this comment Tesseract Issue #503