SkiaSharp: Linux : System.DllNotFoundException: Unable to load DLL 'libSkiaSharp'

Description

I have a .Net Core 2.0 web api running in a linux docker container locally. Ive copied libSkiaSharp to the /app and /app/bin/…/Debug and Release folders just to be sure. My dockerfile installs libfontconfig1. Running ldd libSkiaSharp.so I see:

root@65c88e99a65f:/app# ldd libSkiaSharp.so
        linux-vdso.so.1 (0x00007ffcd954a000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f92d82fc000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f92d80f8000)
        libfontconfig.so.1 => /usr/lib/x86_64-linux-gnu/libfontconfig.so.1 (0x00007f92d7eba000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f92d7bb6000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f92d799f000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f92d7600000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f92d8d90000)
        libfreetype.so.6 => /usr/lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f92d7351000)
        libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f92d7127000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f92d6f0d000)
        libpng16.so.16 => /usr/lib/x86_64-linux-gnu/libpng16.so.16 (0x00007f92d6cda000)

When I call the first action that uses SkiaSharp, I get the dreaded error:

{System.TypeInitializationException: The type initializer for 'SkiaSharp.SKAbstractManagedWStream' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'libSkiaSharp': The specified module or one of its dependencies could not be found.
 (Exception from HRESULT: 0x8007007E)
   at SkiaSharp.SkiaApi.sk_managedwstream_set_delegates(IntPtr pWrite, IntPtr pFlush, IntPtr pBytesWritten, IntPtr pDestroy)
   at SkiaSharp.SKAbstractManagedWStream..cctor()
   --- End of inner exception stack trace ---
   at SkiaSharp.SKAbstractManagedWStream..ctor(Boolean owns)
   at SkiaSharp.SKManagedWStream..ctor(Stream managedStream)
...

Code

n/a

Expected Behavior

It should load the so file.

Actual Behavior

It either cant find the so file or it cant find one of it’s dependencies.

Basic Information

  • Version with issue: 1.60.0
  • Last known good version: ?
  • IDE: Visual Studio
  • Platform Target Frameworks:
    • Linux: asp.netcore 2.08 docker image which I Debian Jessie - so it that like 16.10?
  • Target Devices:
    • Web app

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 35 (11 by maintainers)

Most upvoted comments

@jackyloo, since the v1.68 release, you no longer need to do all this work. Just install the SkiaSharp.NativeAssets.Linux package - https://github.com/mono/SkiaSharp/issues/312