Skip to content

DllNotFoundException running in Debian 12 (Bookworm) #1786

@kobruleht

Description

@kobruleht

test.zip

Steps to reproduce

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

Add windows and linux nuGet packages:

Image
  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
Image
  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
...

Solution is attached

If Debian 11 packages are installed, error

libOpenCvSharpExtern.so: undefined symbol: ZN7Imf_2_514ChromaticitiesC1ERKN9Imath_2_54Vec2IfEES5_S5_S5

Occurs. libOpenCvSharpExtern.so does not run in Debian 12.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions