Skiasharp: [BUG] DllNotFoundException: Unable to load shared library 'libSkiaSharp' or one of its dependencies.

Created on 25 Apr 2019  路  15Comments  路  Source: mono/SkiaSharp

Description

SkiaSharp does not work under MacOS and Ubuntu 18.04. I have a .net core 1.1 web application (vanilla stuff). It builds and runs fine, but when I access skia it results in the following error:

`DllNotFoundException: Unable to load shared library 'libSkiaSharp' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibSkiaSharp: cannot open shared object file: No such file or directory

SkiaSharp.SkiaApi.sk_memorystream_new()
SkiaSharp.SKMemoryStream..ctor()
SkiaSharp.SKMemoryStream..ctor(byte[] data)
SkiaSharp.SKBitmap.Decode(byte[] buffer)
ImageProcessor.ResizePng(byte[] data, int size) in ImageProcessor.cs

Code

   internal static class ImageProcessor
    {
      public  static byte[] ResizePng(byte[] data, int size)
        {
            using (var bitmap = SKBitmap.Decode(data))
            {
                var widthHeight = Math.Min(bitmap.Width, bitmap.Height);
                var scale = (float)size / widthHeight;
                var newInfo = new SKImageInfo((int)(bitmap.Width * scale), (int)(bitmap.Height * scale));

                using (var scaled = bitmap.Resize(newInfo, SKFilterQuality.High))
                    return ToPngData(scaled);
            }
        }

Expected Behavior

It works fine under windows and should also under MacOS and Linux

Actual Behavior

see above.

Basic Information

  • Version with issue: 1.68.0
  • IDE: Visual Studio / Visual Studio Code
  • Platform Target Frameworks: netstandard2.0/netcoreapp2.2

    • Linux: Ubuntu 18.04

    • macOS: current

    • Windows Classic: (it works under windows 10 1809)

Screenshots

Reproduction Link

All 15 comments

Same here with Ubuntu 19.04 and dotnet-sdk from snap

https://github.com/mono/SkiaSharp/issues/453#issuecomment-367428176

does this resolve your problem?

beside, if the related libs the libSkiaSharp.so refers are missing in your OS, the OS will still report libSkiaSharp.so is missing, so it's better to ensure that your libs are all installed properly.

Make sure you install the SkiaSharp.NativeAssets.Linux package as that contains the binaries for Ubuntu and various other Debian-based Linux distros.

As mentioned in some places, make sure you have the SkiaSharp.NativeAssets.Linux package installed for Linux and the dependencies. Typically it is just fontconfig, but some distros need different things.

Run into the same issue on Ubuntu 18.04
Adding SkiaSharp.NativeAssets.Linux didn't help, but adding SkiaSharp.NativeAssets.Linux.NoDependencies resolved the issue.

@WonderD that might be because you are missing the fontconfig dependency.

Usually you can just install that from apt-get:

apt-get install -y libfontconfig1

Just commenting, in case this will benefit somebody else who stumbles on the same issue. In my case we are using a third-party library that depends on SkiaSharp. Our application is using .NET Core 3.1, and it's running in Docker containers on top of Ubuntu 16.04.

In our troubleshooting case, we had to do BOTH of the following steps to get SkiaSharp to work. I tested both of them individually, and neither one alone solves it, but both of them together does solve it.

  1. Adding the following line to dockerfile, to install necessary libraries inside the container:
    RUN apt-get update && apt-get install -y libfontconfig1
  2. Including the SkiaSharp.NativeAssets.Linux nuget package (version 1.68.3) to the .NET Core project where SkiaSharp is used.

@VesaVainio
Thx a lot. You made my day. My web application is also using .NET Core 3.1, and it's running in Docker containers on top of Ubuntu 18.04. Would be nice if these requirements would be mentioned clearly in the SkiaSharp readme.

@VesaVainio
Same here. Thank you very much for the hint!

I'm using .NET Core 3.1 on a amd64 Ubuntu 20.04 docker (3.1-focal https://hub.docker.com/_/microsoft-dotnet-core-runtime/ )
SkiaSharp 1.68.1
SkiaSharp.NativeAssets.Linux.NoDependencies 1.68.1

at SkiaSharp.SkiaApi.sk_colortype_get_default_8888() System.DllNotFoundException: Unable to load shared library 'libSkiaSharp' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibSkiaSharp: cannot open shared object file: No such file or directory

I've tried : RUN apt-get update && apt-get install -y libfontconfig1 still the same error
Any ideas?

I'm using .NET Core 3.1 on a amd64 Ubuntu 20.04 docker (3.1-focal https://hub.docker.com/_/microsoft-dotnet-core-runtime/ )
SkiaSharp 1.68.1
SkiaSharp.NativeAssets.Linux.NoDependencies 1.68.1

at SkiaSharp.SkiaApi.sk_colortype_get_default_8888() System.DllNotFoundException: Unable to load shared library 'libSkiaSharp' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibSkiaSharp: cannot open shared object file: No such file or directory

I've tried : RUN apt-get update && apt-get install -y libfontconfig1 still the same error
Any ideas?

Ok we got this working on a couple of targets - here is the note in our readme

SkiaSharp doesn't have inbuilt support for linux - it has: win-x86 win-x64 win10-x86 win10-x64 win10-arm tizen-x86 tizen-armel osx
To have linux support the following nugets are required:
jellyfin.skiasharp.nativeassets.linuxarm : linux-arm linux-arm64
SkiaSharp.NativeAssets.Linux.NoDependencies : linux-x64 (Tested on AMD)

@philipogorman there is the SkiaSharp.NativeAssets.Linux package as well. Both the SkiaSharp.NativeAssets.Linux.* packages should also have the ARM and ARM64 if you are using the new v2 version of SkiaSharp. It also has support for Alpine.

I have this info in the release notes, but I should probably move it to the main readme. https://github.com/mono/SkiaSharp/releases/tag/v2.80.0#additional

@mattleibow thanks for the info! I think we can move to the newer versions (2.x) soon.

Any info on how to fix this? I have the SkiaSharp.NativeAssets.Linux package but the program can't find it

Was this page helpful?
0 / 5 - 0 ratings