-
Notifications
You must be signed in to change notification settings - Fork 543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Linux : System.DllNotFoundException: Unable to load DLL 'libSkiaSharp' #517
Comments
As an aside, it would be cool if there was some better documentation or a sample app showing how to set this up. I've had to dig around the interwebs for a day to get this far. Running everything on windows is a dream. I mistakenly thought linux would be as easy. I should have known better. Once I get this working I promise to blog it. |
The first thing to check is to make sure the libSkiaSharp.so lives next to the SkiaSharp.dll. If this doesn't help, could you share your Dockerfile? |
So that's really curious. I cant see SkiaSharp.dll anywhere in the container or on my windows build. GAC? |
Here's the docker file:
|
The API is a netcore2.0 build. It references a netstandard2.0 class lib:
I added a package ref for SkiaSharp to the Api project also, just in case. Neither of the projects has SkiaSharp.dll in the output folders. |
In the container: |
Oh, I see your docker and build is quite different to the standard one Im using. I'll try that... after a beer or two. Cheers |
@Jonesie I created a new Web API, and it also fails for me - I have spent the last 3 hours trying to figure out why. I will update s soon as I figure out what is causing the file to not be found. |
Struggled enough, going to contact someone who knows ;) |
I also created a new web api and published using -r linux-x64 and also had the prebuilt libskiasharp.so copied to the output. The app started ok but didnt respons to web requests:
So Im not sure if it found the so - maybe not. Doing it this way produces a Self Contained Deployment. I didnt need to update the csproj fle - it seems publish -r RID is enough to do the correct build. My docker file is:
Building the compose from VS seems to do something different. I dont get the SDD output, just the normal windows looking files. Weird, but probably something I did. I then tried to make a similar change to my real app and all hell broke lose. Lots of nuget downgrade warnings. NU1605. Sigh... |
All right, I think I discovered something. This is my current code - this is pretty mush the same as the same as the default template, but with SkiaSharp and libSkiaSharp.so added: This thing I noticed was that it runs from the command line, see Visual Studio does something else... Not sure what, I hope to talk to Docker/VS guys and find out. |
I think I get it now, although I dont have anything working quite yet. docker-compose -f "C:\Dev\rc\docker-compose.yml" -f "C:\Dev\src\docker-compose.override.yml" -f "C:\Dev\src\obj\Docker\docker-compose.vs.debug.g.yml" -p dockercompose10230428442250841413 --no-ansi up -d --build --force-recreate --remove-orphans The main thing with this is that it sets the volume for /app to the source folder for the project:
So when I bash into the container Im just seeing my own hdd and if I create the image using docker build then I see the correct (?) linux binaries. This is hideous black magic crap that I thought Microsoft had learned not to do! |
Oh and that compose file also has this:
Which I think should be 'final' |
Yes! Fixed it. I copied the so file to C:\Users\peter\.nuget\packages\skiasharp\1.60.0\lib\netstandard1.3 and restarted the container from VS. Works fine. This sounds sort of obvious now I think about it... I'll see if I can deploy to AWS ECS with my scripted image build. |
I suppose that is fine for debugging... What if you copy the .so to the working directory that is used by the VS compose? Does that work? I think I must create a NuGet for each Linux platform (sharing what we can) so that you can just add that. I need to investigate moving all the native files out of the core package as it is getting quite huge now |
Ive got everything working again now. I found some problems with my image build but I also managed to get a stand-alone build working nicely. I'm writing up a blog post now. |
Ahhh. NUGET_FALLBACK_PACKAGES=/root/.nuget/fallbackpackages |
Ah, that was a good read. Thanks for looking around and debunking the magic. |
Hello @mattleibow and @Jonesie, I am trying to get the .NetCore sample to run on my Ubuntu 18.04 machine and I think I have the same issue. Basically all I did was to download the samples from the latest release 1.60.1, open the solution in Monodevelop and run it, and I got the following error. Unhandled Exception: System.TypeInitializationException: The type initializer for 'SkiaSharp.SKImageInfo' threw an exception. ---> 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 Press any key to continue... I tried coping the libSkiaSharp.so file to where the SkiaSharpSample.dll was being created and I doesn't seem to make any difference. I have also tried to compile the libSkiaSharp.so myself using the new and legacy methods on the wiki but they have both failed. @mattleibow I have read that the libSkiaSharp.so was built in Ubuntu 14.04, does that mean that it only works in 14.04? Am I doing something wrong ? What I am supposed to do with the libSkiaSharp.so file? Thanks in advance! |
Hey I have found out the issue after some inspiration from @Jonesie blog post. To run the GTK example just put the file in /home/alexandre/Downloads/samples/Basic/Gtk/SkiaSharpSample/bin/Debug/ |
I had this issue when running in one of the dotnet runtime docker images. By enabling LD_DEBUG=all env variable, I found out that it was due to missing dependencies of libSkia. I needed to add the following two packages, libfreetype6 libfontconfig1 |
Has anyone found a foolproof way of using SkiaSharp in a .NET Core 2.1 Linux image (ideally alpine, for size)? No-matter what I try, I always endup with |
http://jonesie.kiwi/2018/05/16/skiasharp-on-a-linux-container/ |
Thanks @Jonesie. Confirmed that worked for non-alpine versions. Here's what mine looks like:
If I get one that works for Alpine, I'll post that too. |
Alpine may not work as it is a very different Linux to what is used to compile libSkiaSharp. You may have to compile your own. I believe it has to do with the fact that Debian uses glibc and Alpine uses something else. AFK ATM, but I think it's that. |
Thanks for the info @mattleibow. |
Closing this issue as it mostly has been resolved. New NuGet packages will be released to avoid all this work. To support Alpine, please add your vote/comment here so we can prioritize: #453 |
It shows "Service Unavailable" when I hit the link, would you mind sharing your solution again, please? |
Dang. VM died. It's back now. |
Hi, I'm using SkiaSharp on a Synology NAS running Linux. I have had SkiaSharp working just fine but since I upgraded to .NET Core 2.2 and SkiaSharp 1.68 I have had this issue with DllNotFound. Have tried adding the NativeAssets-package but still get the same error. Have posted a question on Stack Overflow here. Don't know what to try really. Any suggestions? |
@automagisk what linux are you running? Also, is it possible to make sure SkiaSharp 1.60.3 works on your upgraded 2.2 or SkiaSharp 1.68.0 runs on the older 2.1. Just need to confirm which one broke which. Note, we upgraded or build bot to Ubuntu 16.04 for new GCC. It was working on the Ubuntu 14.01, but maybe there is another issue. |
Synology DSM uses a custom Linux version it seems. Just tried reverting to 1.60.3 and got the same error so it looks like it's Core 2.2. Update: Looks to be something else that's wrong. I have reverted to Core 2.0 and 1.60.0 and it still doesn't work. Mmmm weird. I have to keep trying and reverting until it works. |
OK, :( |
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:
When I call the first action that uses SkiaSharp, I get the dreaded error:
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
The text was updated successfully, but these errors were encountered: