0

Steps to reproduce

  1. In Visal Studio create .NET 9 console application.

Add OpenCvSharp 4 Windows and Linux nuGet packages:

enter image description here

  1. Create program.cs file:
using OpenCvSharp;
using Mat src = new Mat();
Console.WriteLine(src);
Console.ReadLine();
return 0;

  1. Publish application to Linux to folder

enter image description here

  1. Copy files to Debian 13.
  2. Copy libtesseract.so.4 from tesseract installation.
  3. Run application.

Observed:

Unhandled exception. System.TypeInitializationException: The type initializer for 'OpenCvSharp.Internal.NativeMethods' threw an exception.
 ---> System.DllNotFoundException: Unable to load shared library 'OpenCvSharpExtern' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable:
/var/www/kustuta/OpenCvSharpExtern.so: cannot open shared object file: No such file or directory
libtesseract.so.4: cannot open shared object file: No such file or directory
libOpenCvSharpExtern.so: cannot open shared object file: No such file or directory
/var/www/kustuta/OpenCvSharpExtern: cannot open shared object file: No such file or directory
/var/www/kustuta/libOpenCvSharpExtern: cannot open shared object file: No such file or directory

   at OpenCvSharp.Internal.NativeMethods.redirectError(CvErrorCallback errCallback, IntPtr userdata, IntPtr& prevUserdata)
   at OpenCvSharp.Internal.ExceptionHandler.RegisterExceptionCallback()
   at OpenCvSharp.Internal.NativeMethods.LoadLibraries(IEnumerable`1 additionalPaths)
   at OpenCvSharp.Internal.NativeMethods..cctor()
   --- End of inner exception stack trace ---
   at OpenCvSharp.Internal.NativeMethods.core_Mat_new1(IntPtr& returnValue)
   at OpenCvSharp.Mat..ctor()
   at Program.<Main>$(String[] args) in C:\OpenCvShaptLinuxTest\Program.cs:line 2
Aborted

Actually libraries exist:

 ls -l libOpenCvSharpExtern.so
-rw-r--r-- 1 debian debian 73229704  7. mai   03:37 libOpenCvSharpExtern.so
 ls -l libtesseract.so.4
-rw-r--r-- 1 root root 3516952 11. jaan   2023 libtesseract.so.4


 ldd OpenCvSharpTesseractReceiptDemo
        linux-vdso.so.1 (0x00007ffe803fc000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f30d00bb000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f30d00b6000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f30cfe00000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f30cfd20000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f30d0096000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f30cfb3e000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f30d00e7000)

libOpenCvSharpExtern.so Some references are not resolved:

ldd libOpenCvSharpExtern.so
        linux-vdso.so.1 (0x00007ffe83fad000)
        libtesseract.so.4 => not found
        libgtk-x11-2.0.so.0 => not found
        libgdk-x11-2.0.so.0 => not found
        libcairo.so.2 => /lib/x86_64-linux-gnu/libcairo.so.2 (0x00007fe5720dc000)
        libgdk_pixbuf-2.0.so.0 => /lib/x86_64-linux-gnu/libgdk_pixbuf-2.0.so.0 (0x00007fe5720ae000)
        libgobject-2.0.so.0 => /lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007fe57204f000)
        libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007fe571f17000)
        libavcodec.so.58 => not found
        libavformat.so.58 => not found
        libavutil.so.56 => not found
        libswscale.so.5 => not found
        libjpeg.so.8 => not found
        libpng16.so.16 => /lib/x86_64-linux-gnu/libpng16.so.16 (0x00007fe571ee1000)
        libtiff.so.5 => not found
...

Test solution is in https://github.com/user-attachments/files/22440565/test.zip

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.