shimat / opencvsharp

OpenCV wrapper for .NET
Apache License 2.0
5.36k stars 1.15k forks source link

opencvsharp4.9 + ubuntu 20.04 + NET6.0 + Docker Unable to load shared library 'OpenCvSharpExtern' or one of its dependencies #1659

Closed shihuang999 closed 6 months ago

shihuang999 commented 6 months ago

Summary of your issue

my program file info is below:

image

When I Run Code var mat = new Mat(); on Ubuntu20.04 in docker container Throw the exception :

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 setting the LD_DEBUG environment variable: 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()

image

I Use ldd to check, all is OK, image

I use LD_DEBUG=Libs to run ,the info is below

image

hope for your response .thanks.

Environment

opencvsharp4.9 + ubuntu 20.04 + NET6.0 + Docker

What did you do when you faced the problem?

Write here

Example code:

   static void Main(string[] args)
   {
       Console.WriteLine("Hello, World!");
       var mat = new Mat();
   }

Output:

paste your output

What did you intend to be?

shihuang999 commented 6 months ago

I solved it I should do "cp libOpenCvSharpExtern.so /usr/lib".