C
C#3mo ago
VExcess

Install SkiaSharp

I'm completely new to C#. I'm trying to install a package but can't figure out how. What is going wrong?
$ nuget install SkiaSharp
Feeds used:

Installing package 'SkiaSharp' to '/home/vexcess/Downloads/cstest'.
Unable to find package 'SkiaSharp'
$ nuget install SkiaSharp
Feeds used:

Installing package 'SkiaSharp' to '/home/vexcess/Downloads/cstest'.
Unable to find package 'SkiaSharp'
16 Replies
VExcess
VExcessOP3mo ago
I'm on Linux if that has to do with anything
jcotton42
jcotton423mo ago
you'll want to use dotnet add package <ID>, there's rarely need for the nuget cli these days.
jcotton42
jcotton423mo ago
not sure why they'd tell you to do that, must've been written a while ago
VExcess
VExcessOP3mo ago
the readme was last updated 5 months ago ¯\_(ツ)_/¯
jcotton42
jcotton423mo ago
though, i also noticed feeds used is blank, that's odd try dotnet add, does it work?
VExcess
VExcessOP3mo ago
well it seemed to install SkiaSharp, but now when I run my app it can't locate the library
vexcess@vexcess-IdeaPad-5-Pro-16ACH6:~/Downloads/cstest$ dotnet run
Hello World!
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 using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable:
/usr/lib/dotnet/shared/Microsoft.NETCore.App/8.0.8/libSkiaSharp.so: cannot open shared object file: No such file or directory
/home/vexcess/Downloads/cstest/bin/Debug/net8.0/libSkiaSharp.so: cannot open shared object file: No such file or directory
/usr/lib/dotnet/shared/Microsoft.NETCore.App/8.0.8/liblibSkiaSharp.so: cannot open shared object file: No such file or directory
/home/vexcess/Downloads/cstest/bin/Debug/net8.0/liblibSkiaSharp.so: cannot open shared object file: No such file or directory
/usr/lib/dotnet/shared/Microsoft.NETCore.App/8.0.8/libSkiaSharp: cannot open shared object file: No such file or directory
/home/vexcess/Downloads/cstest/bin/Debug/net8.0/libSkiaSharp: cannot open shared object file: No such file or directory
/usr/lib/dotnet/shared/Microsoft.NETCore.App/8.0.8/liblibSkiaSharp: cannot open shared object file: No such file or directory
/home/vexcess/Downloads/cstest/bin/Debug/net8.0/liblibSkiaSharp: cannot open shared object file: No such file or directory

at SkiaSharp.SkiaApi.sk_colortype_get_default_8888()
at SkiaSharp.SKImageInfo..cctor()
--- End of inner exception stack trace ---
at SkiaSharp.SKImageInfo..ctor(Int32 width, Int32 height, SKColorType colorType, SKAlphaType alphaType)
at MyApp.Main() in /home/vexcess/Downloads/cstest/Program.cs:line 9
vexcess@vexcess-IdeaPad-5-Pro-16ACH6:~/Downloads/cstest$ dotnet run
Hello World!
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 using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable:
/usr/lib/dotnet/shared/Microsoft.NETCore.App/8.0.8/libSkiaSharp.so: cannot open shared object file: No such file or directory
/home/vexcess/Downloads/cstest/bin/Debug/net8.0/libSkiaSharp.so: cannot open shared object file: No such file or directory
/usr/lib/dotnet/shared/Microsoft.NETCore.App/8.0.8/liblibSkiaSharp.so: cannot open shared object file: No such file or directory
/home/vexcess/Downloads/cstest/bin/Debug/net8.0/liblibSkiaSharp.so: cannot open shared object file: No such file or directory
/usr/lib/dotnet/shared/Microsoft.NETCore.App/8.0.8/libSkiaSharp: cannot open shared object file: No such file or directory
/home/vexcess/Downloads/cstest/bin/Debug/net8.0/libSkiaSharp: cannot open shared object file: No such file or directory
/usr/lib/dotnet/shared/Microsoft.NETCore.App/8.0.8/liblibSkiaSharp: cannot open shared object file: No such file or directory
/home/vexcess/Downloads/cstest/bin/Debug/net8.0/liblibSkiaSharp: cannot open shared object file: No such file or directory

at SkiaSharp.SkiaApi.sk_colortype_get_default_8888()
at SkiaSharp.SKImageInfo..cctor()
--- End of inner exception stack trace ---
at SkiaSharp.SKImageInfo..ctor(Int32 width, Int32 height, SKColorType colorType, SKAlphaType alphaType)
at MyApp.Main() in /home/vexcess/Downloads/cstest/Program.cs:line 9
this is my code
using System;
using SkiaSharp;

public class MyApp {

static public void Main() {
Console.WriteLine("Hello World!");

var imageInfo = new SKImageInfo(
width: 400,
height: 400,
colorType: SKColorType.Rgba8888,
alphaType: SKAlphaType.Premul);

var surface = SKSurface.Create(imageInfo);

var canvas = surface.Canvas;

}
}
using System;
using SkiaSharp;

public class MyApp {

static public void Main() {
Console.WriteLine("Hello World!");

var imageInfo = new SKImageInfo(
width: 400,
height: 400,
colorType: SKColorType.Rgba8888,
alphaType: SKAlphaType.Premul);

var surface = SKSurface.Create(imageInfo);

var canvas = surface.Canvas;

}
}
jcotton42
jcotton423mo ago
you're missing a native dep, it would seem from the readme, it seems you need another nuget to get the native lib
VExcess
VExcessOP3mo ago
I installed the native dep too, but I can't get it working. I'm giving up on C# and going back to Rust
canton7
canton73mo ago
What error did you get after installing the native dep?
VExcess
VExcessOP3mo ago
Maybe the issue is SkiaSharp and not dotnet. I'm gonna try using CairoSharp instead Actually CairoSharp hasn't been updated in 4 years so it's probaby not worth trying to use wait no, it's GTKsharp?
Licht
Licht3mo ago
@VExcess why don't you use ImageSharp? It's pure C# so it just works anywhere C# works. It's my go to for image manipulation.
Licht
Licht3mo ago
GitHub
GitHub - SixLabors/ImageSharp: :camera: A modern, cross-platform, 2...
:camera: A modern, cross-platform, 2D Graphics library for .NET - SixLabors/ImageSharp
canton7
canton73mo ago
Do be aware that the license isn't necessarily compatible with a commercial product
VExcess
VExcessOP3mo ago
only being able to use the library if your company makes less than $1M per year is unique Not an issue for me though. All the code I've ever written is open source and free to use
Licht
Licht3mo ago
Then you're about to have a good time.
Want results from more Discord servers?
Add your server