[BUG] Unable to load shared library 'libSkiaSharp' or one of its dependencies in AWS Linux

See original GitHub issue

Description

I built out a .NET Core 2.1 API that uses SkiaSharp. Works great on Windows & Mac. Deployed to AWS Amazon Linux 2 (Amazon’s custom version of CentOS). When I hit the endpoint, I get:

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 already added SkiaSharp.NativeAssets.Linux to my project. I tried putting libSkiaSharp.so in my bin folder to no avail.

I took the error’s advice and enabled LD_DEBUG and found the following:

7332:     find library=libSkiaSharp [0]; searching
7332:      search cache=/etc/ld.so.cache
7332:      search path=/lib64/tls:/lib64:/usr/lib64/tls:/usr/lib64(system search path)
7332:trying file=/lib64/tls/libSkiaSharp
7332:trying file=/lib64/libSkiaSharp
7332:trying file=/usr/lib64/tls/libSkiaSharp
7332:trying file=/usr/lib64/libSkiaSharp

So I copied libSkiaSharp.so to /usr/lib64 and then it started working! But this isn’t ideal in my production environment, and I’d much rather it just look locally as opposed to deep in the system. Is there somewhere else I can put it without needing to access the AWS machine it’s running on?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
mattleibowcommented, Nov 4, 2019

If you aren’t doing things with text, or if you are brining your own fonts, you could try https://www.nuget.org/packages/SkiaSharp.NativeAssets.Linux.NoDependencies

This NuGet is the same as SkiaSharp.NativeAssets.Linux, but does not have the fontconfig dependency. The downside is that it doesn’t have the same support of features - mostly font finding. But it can still draw text.

6reactions
f2calvcommented, Oct 13, 2019

I have a similar issue with a .NET Core 3.0 deployment, it was working fine during preview releases of .NET Core 3 up-to preview 9, then seemingly when .NET Core 3.0 final was released it then failed with the same error as you.

Adding the following to my Dockerfile fixed the issue;

  • RUN apt-get update && apt-get install -y libfontconfig1

I guess the underlying image and its dependencies must have changed (regardless of having SkiaSharp.NativeAssets.Linux installed), so maybe this tweak will help…

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found