Skip to content
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

More Pre-Built Linux Libraries #453

Closed
4 of 5 tasks
mattleibow opened this issue Feb 21, 2018 · 81 comments
Closed
4 of 5 tasks

More Pre-Built Linux Libraries #453

mattleibow opened this issue Feb 21, 2018 · 81 comments
Assignees
Milestone

Comments

@mattleibow
Copy link
Contributor

mattleibow commented Feb 21, 2018

Right now there is a pre-built library for Linux x64 that goes with each release. I want to add more to make life easier.

Leave comments and other feedback so that I can add other distros and architectures. Also for feedback is the platforms that a binary can be re-used. (For example, the Ubuntu 14.04 binary can also work on CentOS 7)

This doc has the list for .NET Core:
https://docs.microsoft.com/en-us/dotnet/core/linux-prerequisites?tabs=netcore2x
This is the platforms supported by mono:
https://www.mono-project.com/download/stable/#download-lin

Current Support

Proposed Support

  • Debian (x86)

Dropped

  • Raspberry Pi (ARM) (steps)
    Not actually because we have the PR Build for Linux ARM32 (armhf) and ARM64 (aarch64) #1382 that automatically supports it.
  • CentOS (x64)
    Not really because this should work with the Debian binaries.
  • RHEL 6/7 (x64)
    Not really because this should work with the Debian binaries.

VS bug #733081

@jcyuan
Copy link

jcyuan commented Feb 21, 2018

Ahhhh. a tip although not related to this topic (but it takes a little of my time to settle things done, so this is just for those who are not familiar with linux OS like me):
yum install libfontconfig1-dev will do nothing because there is no such entry. (as mentioned in https://github.com/mono/SkiaSharp/wiki/Building-on-Linux by @mattleibow )
apt-get is only for ubuntu while yum is for redhat (CentOS)
so on RH please do:
yum install fontconfig instead
and for OpenGL lib:
yum install libGL (note: I'm not sure whether this one is corresponding to libglu1-mesa-dev or not)

so steps to install libSkiaSharp for your CentOS:
1, copy the published .so file by @mattleibow to your NetCore container folder on your OS https://github.com/mono/SkiaSharp/releases/tag/v1.59.3
2, ldd libSkiaSharp.so to inspect dependencies (normally it will only show libfontconfig.so.1 not found)
3, yum install fontconfig
4, yum install libGL (emmm, have to be confirmed)

Actually i found that the lib works well after only setp 3 is done. (maybe I do not use some of OpenGL features?)

done, what a good day.

@mattleibow
Copy link
Contributor Author

@jcyuan OpenGL is not required, but will be used if you are using the GPU surfaces. It is also loaded at runtime, and thus not needed at compile-time.

@mattleibow
Copy link
Contributor Author

@jcyuan Could the package name for fontconfig may differ across distros?

@jcyuan
Copy link

jcyuan commented Feb 22, 2018

@mattleibow I don't know, actually once installed, I found the lib you mentioned 'libfontconfig.so.1' is located in /usr/lib64/ path, and actually the 'libSkiaSharp.so' uses it correctly as the ldd command shows libSkiaSharp.so refers to this path.
so I think that is only a different package name used between apt-get and yum?

@mattleibow mattleibow changed the title More Pre-Build Linux Libraries More Pre-Built Linux Libraries Mar 25, 2018
@mattleibow
Copy link
Contributor Author

To make life easier for everyone, I moved code around and added a new target to the GN files. Now, the native libSkiaSharp build is done with GN and ninja directly: https://github.com/mono/SkiaSharp/wiki/Building-on-Linux

@mattleibow
Copy link
Contributor Author

@wuzzeb
Copy link

wuzzeb commented Nov 30, 2018

Just FYI, I just used SkiaSharp.NativeAssets.Linux version 1.68.0-preview28 from nuget on ArchLinux and basic drawing works! I haven't done extensive testing, but the library does initialize and I can draw on a canvas and export the SKImage to a PNG.

@mattleibow
Copy link
Contributor Author

That is great news!

@knocte
Copy link

knocte commented Dec 5, 2018

Quoting from https://github.com/mono/SkiaSharp/releases/tag/v1.68.0:

More builds can be requested by leaving a comment on #453.

I'm wondering, what if I want to use SkiaSharp.Views.Forms in Linux? Do I need a Linux flavour of this nuget (https://www.nuget.org/packages/SkiaSharp.Views.Forms) or is it enough to have the SkiaSharp.NativeAssets.Linux dll in the same folder of the app?

Thanks

@mattleibow
Copy link
Contributor Author

mattleibow commented Dec 5, 2018

The SkiaSharp.Views.Forms NuGet is the managed views for Xamarin.Forms, and SkiaSharp.NativeAssets.Linux is the native engine. The reason that you may not have the GTK# working is that we don't yet support that. See #379

@kieronlanning
Copy link

+1 for an Alpine NuGet build/ package please...!

@AlexNosk
Copy link

https://www.nuget.org/packages/Goelze.SkiaSharp.NativeAssets.AlpineLinux/ does not work with the latest version of SkiaSharp. Can AlpineLinux native assets become "official" and be published with each new version of SkiaSharp, like SkiaSharp.NativeAssets.Linux?

@mattleibow
Copy link
Contributor Author

We could have a look at that now. I recently changed things so that the Linux native bits actually all build on Docker.

I hope I did it right to get alternate distros super easy. It should just be a docker file link this
https://github.com/mono/SkiaSharp/blob/master/scripts/Docker/ubuntu16/amd64/Dockerfile

And then add a chunk to the yaml
https://github.com/mono/SkiaSharp/blob/master/scripts/azure-pipelines.yml#L204

That should be all that is required. If not, then I didn't do so well and we need to fix that.

What actually runs is a docker build and then a docker run with a volume to the source
https://github.com/mono/SkiaSharp/blob/master/scripts/azure-templates-bootstrapper.yml#L125

Maybe have a go and see what happens.

@Gillibald
Copy link
Contributor

Gillibald commented Feb 12, 2020

We could add a linux-musl-x64 runtime that way nothing gets in conflict with the regular builds.

@mattleibow
Copy link
Contributor Author

Oh, yeah. I'd like to add the core platforms that .NET Core supports to the main NuGet. Right now I just have linux-x64, so we can totally add things link Apline/musl. I just haven't gotten around to actually creating the Dockerfiles. But, I do see we have some links in this thread so far.

@EraYaN
Copy link

EraYaN commented Feb 12, 2020

For ARM it's a bit in flux right now, my old attempt https://github.com/EraYaN/EraYaN.SkiaSharp.NativeAssets.LinuxArm still works (and we use/ship it successfully for some time now with Jellyfin) but docker is doing some funky stuff right now to make it easier, although it has not fully landed yet (ie. you need qemu to do a lot of things or just plain cross compile and then create a new docker image with the result.)

@saskathex
Copy link

+1 for Ubuntu arm64 (Nvidia Jetson Nano)

@Octarines
Copy link

+1 for Alpine

@JMan7777
Copy link

JMan7777 commented May 26, 2020

Hi,
+1 for Alpine

Does it work on the latest official Ubuntu 20.04 based container images available at:
https://hub.docker.com/_/microsoft-dotnet-core-sdk/
?

Thx.

@tahayazici95
Copy link

tahayazici95 commented Jun 12, 2020

Hi,
+1 for Alpine, please.

For those interested I got the library working on Alpine by installing:
Goelze.SkiaSharp.NativeAssets.AlpineLinux v1.68.0.1
SkiaSharp v1.68.0

And included this line in my docker file:
RUN apk --no-cache add fontconfig
(remember: you need the fontconfig to be in the deployed image, so it matters where you place it in the docker file)

Thanks,

@benosmond
Copy link

+1 for Alpine.

@mattleibow
Copy link
Contributor Author

Hi folks. I know that Alpine is a high priority, so working on that. Thanks to the community for stepping in. Right now I am just finishing up the previews for Web Assembly!

@JMan7777 it should work with the SkiaSharp.NativeAssets.Linux package on most Debian-based - including most Ubuntu versions.

@mattleibow
Copy link
Contributor Author

FOLKS!!! After much delay and +1's, Alpine is now in the box!!! Just merged a Alpine x64 archive into master and will go out as a preview as soon as CI finishes up!

Right now, I am building using Alpine 3.9 but it runs all the way back to Alpine 3.7 (at least).

There are 2 builds, the default which requires the usual fontconfig install: apk add --no-cache fontconfig. And, the is the "no dependencies" build which drops some advanced font features but does not need any additional packages.

I just went for x64 right now, but if there are other architectures or platforms, keep up with the +1 for <OS> <Arch> and I'll try make sure to get it in.

You can also have a look t #1339 and see just how to submit a PR to add any Linux platform that is needed. Then you don't have to worry about maintaining it - because I'll have to 😉

@mattleibow
Copy link
Contributor Author

Adding armv7a hf and arm64/aarch64 in #1382

@mattleibow
Copy link
Contributor Author

mattleibow commented Jul 8, 2020

Almost ready to close this now... Does anyone still use x86 Linux anymore? Is that still a thing?

What additional Linux variants do we actually need? Most things just work fine with the old Debian binaries.

@xiangzhai
Copy link

:mips-interest

@xiangzhai
Copy link

Hi @mattleibow

There is building libSkiaSharp.so document, but no libHarfBuzzSharp.so, how to build libHarfBuzzSharp.so?

Thanks,
Leslie Zhai

@mattleibow
Copy link
Contributor Author

@xiangzhai you should be able to also build harfbuzz by swapping out the gn target from SkiaSharp to Harfbuzz.

Another way to build is you don't mind installing mono is to just use cake and run with the bootstrapper. The you can just execute the externals-linux cake task.

@xiangzhai
Copy link

Hi @mattleibow

Thanks for your teaching!

Leslie Zhai

@rosenbjerg
Copy link

+1 for linux-musl-arm64

@mattleibow
Copy link
Contributor Author

Thanks for all the votes folks!

I'm going to finally close this issue since we got most of the linux distros that are supported. If one is specifically needed, then feel free to open an issue for that one.

However, if you have a special linux that you need SkiaSharp for, you can probably modify one of the Docker files that we use for your distro: https://github.com/mono/SkiaSharp/tree/main/scripts/Docker

@alerine1
Copy link

I am trying to deploy an app using the SkiaSharp libraries to AKS and I get this error:

System.AggregateException: One or more errors occurred. (The type initializer for 'SkiaSharp.SKData' threw an exception.) (The type initializer for 'SkiaSharp.SKData' threw an exception.)
---> System.TypeInitializationException: The type initializer for 'SkiaSharp.SKData' 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
at SkiaSharp.SkiaApi.sk_data_new_empty()
at SkiaSharp.SKData..cctor()
--- End of inner exception stack trace ---
at SkiaSharp.SKData.Create(IntPtr address, Int32 length)
at SkiaSharp.SKBitmap.Decode(ReadOnlySpan1 buffer) at SkiaSharp.SKBitmap.Decode(Byte[] buffer) at System.Threading.Tasks.TaskReplicator.Replica.Execute() at AssetExtractor.PowerpointImageExtractor.<>c__DisplayClass12_0.<ConvertImages>b__0(ImageSize size) in /home/vsts/work/1/s/src/backend/AssetExtractor/ImageExtractor.cs:line 141 at System.Threading.Tasks.Parallel.<>c__DisplayClass33_02.b__0(Int32 i)
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location ---

But if I deploy the very same code to a Linux (Ubuntu) Azure app service, it works without any issues

This is the base Docker image getting deployed to AKS

mcr.microsoft.com/dotnet/aspnet:6.0

I am converting images from a other formats to .webp format

image

Any ideas

Thanks

@ghost ghost locked as resolved and limited conversation to collaborators Aug 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests