opencvsharp icon indicating copy to clipboard operation
opencvsharp copied to clipboard

ubuntu22, net6.0 use OpenCvSharp4 throw exception: Unable to load shared library 'OpenCvSharpExtern' or one of its dependencies.

Open cwf689 opened this issue 2 years ago • 11 comments

Environment:

system: ubuntu22 , arm64 libs: OpenCvSharp4 ver 4.8.0.20230708 OpenCvSharp4.Extensions ver 4.8.0.20230708 OpenCvSharp4.runtime.linux-arm ver 4.8.0.20230708 OpenCvSharp4.runtime.linux-arm64.cuda ver 4.8.0.20230708

Example code:

using OpenCvSharp; ... var capture = new VideoCapture(0);

Output:

The type initializer for 'OpenCvSharp.Internal.NativeMethods' threw an exception. 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

What did you intend to be?

cwf689 avatar Oct 12 '23 12:10 cwf689

I am getting the same with ubuntu 22 and net 7.0. I think currently there is no support for ubuntu 22?

MoHamzawy avatar Oct 20 '23 10:10 MoHamzawy

I'm also experiencing this. Specifically, I'm trying to run this in a Docker container. I've tried in a .NET 6 container (which uses 20) and a .NET 7 container (which uses 22). I do have the base OpenCvSharp4 and OpenCvSharp4.runtime.ubuntu.20.04-x64 packages referenced in my project.

BradMJustice avatar Oct 26 '23 03:10 BradMJustice

I'm also experiencing this. Specifically, I'm trying to run this in a Docker container. I've tried in a .NET 6 container (which uses 20) and a .NET 7 container (which uses 22). I do have the base OpenCvSharp4 and OpenCvSharp4.runtime.ubuntu.20.04-x64 packages referenced in my project.

Never mind, I was able to get past this by using the docker images located here https://github.com/shimat?tab=packages as my base image.

BradMJustice avatar Oct 26 '23 03:10 BradMJustice

Hey @cwf689, You can try my self compiled ubuntu22.04 mini version as following, I only compiled core, imgproc, imgcodec:

Id Version Size OS Arch
Sdcb.OpenCvSharp4.mini.runtime.centos.7-arm64 NuGet 3.23MB CentOS 7 ARM64
Sdcb.OpenCvSharp4.mini.runtime.centos.7-x64 NuGet 16.75MB CentOS 7 x64
Sdcb.OpenCvSharp4.mini.runtime.debian.11-arm64 NuGet 4.05MB Debian 11 ARM64
Sdcb.OpenCvSharp4.mini.runtime.debian.11-x64 NuGet 18.13MB Debian 11 x64
Sdcb.OpenCvSharp4.mini.runtime.debian.12-arm64 NuGet 4.18MB Debian 12 ARM64
Sdcb.OpenCvSharp4.mini.runtime.debian.12-x64 NuGet 17.47MB Debian 12 x64
Sdcb.OpenCvSharp4.mini.runtime.ubuntu.22.04-arm64 NuGet 4.18MB Ubuntu 22.04 ARM64
Sdcb.OpenCvSharp4.mini.runtime.ubuntu.22.04-x64 NuGet 17.47MB Ubuntu 22.04 x64
Sdcb.OpenCvSharp4.mini.runtime.android-arm64 NuGet 4.04MB Android ARM64

sdcb avatar Nov 13 '23 03:11 sdcb

@sdcb Hey, thank you! Do you have a link to the sources of your "mini" version?

maaft avatar Nov 22 '23 08:11 maaft

@maaft you're right, I created a build instructions (not source code, but like docs) here: https://github.com/sdcb/opencvsharp-mini-runtime/tree/main

sdcb avatar Nov 30 '23 13:11 sdcb

there is a method, my env is ubuntu20.04 x64

  1. copy OpenCvSharpExtern.so to your publish dir
  2. ldd libOpenCvSharpExtern.so | grep found to see whether your system has missed some so/dll for me is:
 root@ubuntu2004:/home/temp/test8/testubuntucv# ldd *.so* | grep found
	liblttng-ust.so.0 => not found
	libtesseract.so.4 => not found
	libgtk-x11-2.0.so.0 => not found
	libgdk-x11-2.0.so.0 => not found
	libdc1394.so.22 => not found
	libavcodec.so.58 => not found
	libavformat.so.58 => not found
	libavutil.so.56 => not found
	libswscale.so.5 => not found
	libIlmImf-2_3.so.24 => not found
  1. to fix this excecute cmd: apt-get install libgtk2.0 lttng-ust libtesseract4 libavcodec58 libavformat58 libavutil56 libswscale5 libdc1394-22-dev libopenexr24

then this nuget dll work well. may be you should change the cmd by your real situation

yangbocheng avatar Dec 08 '23 04:12 yangbocheng

just use what @sdcb says, it works very well in ubuntu-2204 pure system. thanks @sdcb

yangbocheng avatar Dec 08 '23 07:12 yangbocheng

there is a method, my env is ubuntu20.04 x64

  1. copy OpenCvSharpExtern.so to your publish dir
  2. ldd libOpenCvSharpExtern.so | grep found to see whether your system has missed some so/dll for me is:
 root@ubuntu2004:/home/temp/test8/testubuntucv# ldd *.so* | grep found
	liblttng-ust.so.0 => not found
	libtesseract.so.4 => not found
	libgtk-x11-2.0.so.0 => not found
	libgdk-x11-2.0.so.0 => not found
	libdc1394.so.22 => not found
	libavcodec.so.58 => not found
	libavformat.so.58 => not found
	libavutil.so.56 => not found
	libswscale.so.5 => not found
	libIlmImf-2_3.so.24 => not found
  1. to fix this excecute cmd: apt-get install libgtk2.0 lttng-ust libtesseract4 libavcodec58 libavformat58 libavutil56 libswscale5 libdc1394-22-dev libopenexr24

then this nuget dll work well. may be you should change the cmd by your real situation @yangbocheng sorry i am getting errors E: Unable to locate package lttng-ust E: Unable to locate package libdc1394-22-dev E: Unable to locate package libopenexr24 image

mohdshabbeer avatar Dec 08 '23 23:12 mohdshabbeer

Hi @sdcb, are there any pre-built packages of OpenCvSharp4 version 4.10.0.20240616 for Ubuntu 22.04 (mini or full version) available for use?

peter-nguyen-contemi avatar Jul 02 '24 10:07 peter-nguyen-contemi