When trying to run minimal application on linux, exception is thrown
System.DllNotFoundException: Failed to find library "libleptonica-1.78.0.so" for platform x64
So native dependencies aren't included for any platforms other than Windows it seems.
I'm also having this problem when trying to build in travis-ci with linux. Is there a package that can be installed that will bring this file down? I have tried both of the following neither of which helped
sudo apt install tesseract-ocr
sudo apt install libleptonica-dev
I needed to compile this file myself in order to get it working.
I used this docs: https://github.com/tesseract-ocr/tesseract/wiki/Compiling
The problem is that InteropDotNet seems to expect native libleptonica and libtesseract in the according folder (x64 or x86). So if you're lazy as myself, you can install libtesseract-dev
and libleptonica-dev
, copy the *.so files to bin/< Configuration >/netcoreapp3.1/x64 folder, rename them (compiler will you what file is missing) and it suddenly works. Assuming your distro's software sources contain the proper versions, that is ;)
I think the appropriate solution though is to ship the binaries for Linux as it's done for Windows.
I was thinking a better way of dealing with this would be to support
falling back on just using the generic load dynamic library routine (i.e.
standard search paths). That way it should just work provided the libraries
been installed.
Only issue I can think of is it might cause issues with the diagnosing
errors relating to finding or loading the library. Which has been a
consistent pain in the ass.
How does that sound?
On Tue, 28 Jan 2020, 07:13 Arthur, notifications@github.com wrote:
The problem is that InteropDotNet
https://github.com/AndreyAkinshin/InteropDotNet seems to expect native
libleptonica and libtesseract in the according folder (x64 or x86). So if
you're lazy as myself, you can install libtesseract-dev and
libleptonica-dev, copy the .so files to bin//x64 folder, rename them
(compiler will you what file is missing) and it suddenly *works.I think the appropriate solution though is to ship the binaries for Linux
as it's done for Windows.—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/charlesw/tesseract/issues/503?email_source=notifications&email_token=AAB7HSFBQGRE4KQQXT532Q3Q7455HA5CNFSM4KKGHXW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKA4R5A#issuecomment-578930932,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAB7HSDQUHSMSOEPC36WOSDQ7455HANCNFSM4KKGHXWQ
.
I'm having the same issue, I have managed to complile the correct leptonica 1.78.0 and tesseract 4.1.0 because I'm using a Docker image based on Debian buster and it only goes to 1.76 and 4.0.1 but I still have the "System.DllNotFoundException: Failed to find library "libleptonica-1.78.0.so" for platform x64."
I tried copying the .so in the x64 folder as suggester by @arthrp and I also tried with symlinks but it does not work either, I don't know what else to do at this point.
Any idea?
Not sure if this helps but @howff managed to get it working in our repo with this commit. It has some renames of the files in the x64 directory https://github.com/SMI/SmiServices/commit/d97879dd84c7288ca6e472c7f2b0f678bb9a47a3
Thanks, at least it confirms that they need to be called x64\libleptonica-1.78.0.so
and x64\libtesseract41.so
.
Oddly enough this is exactly what I do, I must be wrong somewhere else I guess...
You will need to compile the linux .so for leptonica and tesseract and place them in the x64 directory. Make sure the filenames are x64/libtesseract41.so and x64/libleptonica-1.78.0.so so that the DLLs can find them, BUT you might find that internally the tesseract .so references the leptonica .so by a different name so you might need a symbolic link (or copy) named x64/libleptonica.so.5.3.0
You can use the linux 'ldd' utility to find out if there are any other dependencies missing.
Thanks a lot for trying to help me with this, basically, in my Docker image I have this:
root@st-ocr_service:/usr/local/lib# ls -alh
total 145M
drwxr-xr-x 1 root root 4.0K Feb 7 15:51 .
drwxr-xr-x 1 root root 4.0K Feb 7 15:51 ..
-rw-r--r-- 1 root root 17M Feb 7 14:14 liblept.a
-rwxr-xr-x 1 root root 984 Feb 7 14:14 liblept.la
lrwxrwxrwx 1 root root 16 Feb 7 14:14 liblept.so -> liblept.so.5.0.3
lrwxrwxrwx 1 root root 16 Feb 7 14:14 liblept.so.5 -> liblept.so.5.0.3
-rwxr-xr-x 1 root root 2.6M Feb 7 14:14 liblept.so.5.0.3
-rw-r--r-- 1 root root 123M Feb 7 14:19 libtesseract.a
-rwxr-xr-x 1 root root 1.1K Feb 7 14:19 libtesseract.la
lrwxrwxrwx 1 root root 21 Feb 7 14:19 libtesseract.so -> libtesseract.so.4.0.1
lrwxrwxrwx 1 root root 21 Feb 7 14:19 libtesseract.so.4 -> libtesseract.so.4.0.1
-rwxr-xr-x 1 root root 3.4M Feb 7 14:19 libtesseract.so.4.0.1
drwxr-xr-x 2 root root 4.0K Feb 7 15:51 pkgconfig
And this:
root@st-ocr_service:/app/x64# ls -alh
total 12K
drwxr-xr-x 1 root root 4.0K Feb 7 16:08 .
drwxr-xr-x 1 root root 4.0K Feb 7 15:51 ..
lrwxrwxrwx 1 root root 27 Feb 7 16:03 liblept.so.5 -> /usr/local/lib/liblept.so.5
lrwxrwxrwx 1 root root 27 Feb 7 16:08 libleptonica-1.78.0.so -> /usr/local/lib/liblept.so.5
lrwxrwxrwx 1 root root 36 Feb 7 16:08 libtesseract41.so -> /usr/local/lib/libtesseract.so.4.0.1
Which is consistent with what I got from ldd:
root@st-ocr_service:/app/x64# ldd libtesseract41.so
[...]
liblept.so.5 => /usr/local/lib/liblept.so.5 (0x00007fe735ff6000)
[...]
However, even with this configuration, I still get the System.DllNotFoundException: Failed to find library "libleptonica-1.78.0.so" for platform x64.
which drives me crazy.
Monday morning, fresh coffee, clear mind, I finally got this to work!
My Leptonica and Tesseract compilation weren't correct, I fixed this, and there also was some missing dependencies in my Docker image, now everything is sorted out and working as it should!
I am trying to compile in Windows 10, and deploy on AWS Lambda. I am getting the error on libleptonica-1.78.0.so file missing.
Is there any place I can download it from?
@sudipkumarbhattacharya The linux binaries are linked from one of the previous comments
This is how I fixed it in a Debian 9 server:
cd ~/MyProject/x64
sudo apt install libleptonica-dev
ln -s /usr/lib/x86_64-linux-gnu/liblept.so.5 liblept.so.5
ln -s /usr/lib/x86_64-linux-gnu/liblept.so.5 libleptonica-1.78.0.so
# Installed the repository from https://notesalexp.org/
sudo apt install libtesseract-dev
ln -s /usr/lib/x86_64-linux-gnu/libtesseract.so.4.0.1 libtesseract41.so
The paths and versions might be different in your machine.
Is anyone able to run it against .NET Core 5.0? I'm having issues to compile example console app on Manjaro Linux after updating dependencies and target framework.
leptopnica is OK, libteseract is OK, but the result Console App even tho it compiles, it crashes with segmentation fault
when I run it. Something makes me think that its this .NET wrapper is not working correctly under linux.
Wouldn't it make more sense to just bundle the native dependencies in the package? There are many .net packages that do this rather than requiring that people have exactly the right libs installed (or perform manual steps to copy in those dependencies).
Yes that's certainly an option, does anyone else have any opinions here? I
don't have much experience with Linux so not sure of current best practices
here.
Note I don't have the time to maintain Linux/Mac however will accept pull
requests. Please do raise an issue, or comment on existing issue if
appropriate, to discuss your ideas first though 🙂
On Tue, 16 Mar 2021, 02:49 Alexander Trauzzi, @.*>
wrote:
Wouldn't it make more sense to just bundle the native dependencies in the
package? There are many .net packages that do this rather than requiring
that people have exactly the right libs installed (or perform manual steps
to copy in those dependencies).—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/charlesw/tesseract/issues/503#issuecomment-799527550,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AAB7HSF4QBJ3BHIGK62JFODTDYUAFANCNFSM4KKGHXWQ
.
I think the process would be the same for Windows, macOS and Linux. The Windows library should also be including a static copy too, so maybe start there?
I use wrapper for .NET 4.1.1 and it worked on WSL2 (Ubuntu 20.04) using solution by carloswbarros . But deploing on Docker on AWS it fails with message Failed to find library "libleptonica-1.80.0.so" for platform x64. or sometimes with Failed to find library "libtesseract41.so" for platform x64. I tryied symlinks like
WORKDIR /app/x64
RUN ln -s /usr/lib/x86_64-linux-gnu/liblept.so.5 libleptonica-1.80.0.so
RUN ln -s /usr/lib/x86_64-linux-gnu/libtesseract.so.4.0.1 libtesseract41.so
an it does not help. Also I tried to copy to x64 folder directly from solution folder and same result. Now I think that I have to compile it may be. Actually it is a good idea to have linux library with nuget package installed.
I use wrapper for .NET 4.1.1 and it worked on WSL2 (Ubuntu 20.04) using solution by carloswbarros . But deploing on Docker on AWS it fails with message Failed to find library "libleptonica-1.80.0.so" for platform x64. or sometimes with Failed to find library "libtesseract41.so" for platform x64. I tryied symlinks like
WORKDIR /app/x64
RUN ln -s /usr/lib/x86_64-linux-gnu/liblept.so.5 libleptonica-1.80.0.so
RUN ln -s /usr/lib/x86_64-linux-gnu/libtesseract.so.4.0.1 libtesseract41.so
an it does not help. Also I tried to copy to x64 folder directly from solution folder and same result. Now I think that I have to compile it may be. Actually it is a good idea to have linux library with nuget package installed.
also have this error when I run github workflow and docker instation
This worked fo me in Dockerfile. We had to build libtesseract.so.4.0.1 from source
RUN apt-get update && apt-get install -y libleptonica-dev
RUN apt-get update && apt-get install -y libtesseract-dev
RUN apt-get update && apt-get install -y libc6-dev
RUN apt-get update && apt-get install -y libjpeg62-turbo-dev
RUN apt-get update && apt-get install -y libgdiplus
WORKDIR /app/x64
RUN ln -s /usr/lib/x86_64-linux-gnu/liblept.so.5 liblept.so.5
RUN ln -s /usr/lib/x86_64-linux-gnu/liblept.so.5 libleptonica-1.80.0.so
COPY ./sofile/libtesseract.so.4.0.1 libtesseract41.so
Most helpful comment
Wouldn't it make more sense to just bundle the native dependencies in the package? There are many .net packages that do this rather than requiring that people have exactly the right libs installed (or perform manual steps to copy in those dependencies).