opencvsharp icon indicating copy to clipboard operation
opencvsharp copied to clipboard

Ubuntu 24.04 support

Open marcobudde opened this issue 7 months ago • 6 comments

At the moment there seems to be no support for running OpenCVSharp on the latest Ubuntu LTS (24.04) version.

It would be great to get support for this version.

marcobudde avatar Jul 18 '25 13:07 marcobudde

Hi @marcobudde,

Thanks for reporting this issue — I'm also interested in getting OpenCvSharp running on Ubuntu 24.04.

Just wondering: have you already installed the .NET 6 SDK manually? Ubuntu 24.04 doesn’t include .NET by default, so some features may fail silently if the runtime is missing.

Also, do you get any specific error message or stack trace? It would help to know whether the failure is related to .NET itself or native bindings like OpenCvSharpExtern.so.

Looking forward to more details — happy to help if I can.

mrwangshipei avatar Jul 25 '25 09:07 mrwangshipei

I am using .NET 9 SDK in a Docker container based on Ubuntu 24.04.

.NET 9 is installed like this:

# Install .NET 9
RUN apt-get update && \
    apt-get install -y software-properties-common && \
    add-apt-repository ppa:dotnet/backports && \
    apt-get install -y dotnet-sdk-9.0 aspnetcore-runtime-9.0 && \
    rm -rf /var/lib/apt/lists/*

I use this packages:

    <PackageReference Include="OpenCvSharp4" Version="4.11.0.20250507" />
    <PackageReference Include="OpenCvSharp4.official.runtime.linux-x64" Version="4.11.0.20250507" />
    <PackageReference Include="OpenCvSharp4.runtime.win" Version="4.11.0.20250507" />

The problem is caused by missing dependencies of OpenCvSharpExtern.so:

        libtesseract.so.4 => not found
        libavcodec.so.58 => not found
        libavformat.so.58 => not found
        libavutil.so.56 => not found
        libswscale.so.5 => not found
        libtiff.so.5 => not found
        libIlmImf-2_5.so.25 => not found

Ubuntu 24.04 contains only newer versions of the libraries.

Same code/setup works without problems, when I switch the Docker container to Ubuntu 22.04.

marcobudde avatar Jul 25 '25 10:07 marcobudde

Any update in this please? We are also trying to use the library on Ubuntu 24.04..

Error Message: 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.

AND

....OpenCvSharpExtern.so: cannot open shared object file: No such file or directory

csstag avatar Aug 21 '25 11:08 csstag

This may be helpful: https://github.com/shimat/opencvsharp/blob/main/docker/ubuntu24-dotnet8-opencv4.12.0/Dockerfile

shimat avatar Aug 21 '25 12:08 shimat

Ok, so if anyone else is looking for an Ubuntu 24.04 solution, use the library from nuget.org "OpenCvSharp4.unofficial.runtime.ubuntu.24.04-x64" and make sure that on the Server or Docker the OpenCv Version 4.13 is installed.

csstag avatar Aug 22 '25 10:08 csstag

Also interested of this topic, although my linux port has couple of more headaches to solve...

mpulukkinen avatar Oct 05 '25 06:10 mpulukkinen

OpenCVSharp 4.11.0.20250507 runs fine with dotnet 10 on Ubuntu 25.10.

See here for a minimal repro and instructions: https://github.com/thomai-d/opencvsharp-dotnet10-starter

Thanks, @shimat for the great work and hint with the docker file.

thomai-d avatar Dec 21 '25 07:12 thomai-d