Getting Starting with Silk.NET (on Linux)

Silk.NET's logo

Silk.Net's readme describes itself:

Silk.NET is your one-stop-shop for high-speed .NET multimedia, graphics, and compute; providing bindings to popular low-level APIs such as OpenGL, OpenCL, OpenAL, OpenXR, GLFW, SDL, Vulkan, Assimp, WebGPU, and DirectX.

The documentation is a little bare:

Silk.NET's first page in Documentation section

The tutorial code looks promising so that's where I started. I opened a new solution, pasted in the first example program, and then was immediately greeted by unresolved references. That makes sense – we can't expect to use a library without installing that library somehow. Based off of the example project's references it looks like we only need to install Silk.NET.Input and Silk.NET.Windowing from NuGet. These are currently on version 2.16.0. Now with the libraries in place the example code builds successfully! Unfortunately, on my system I get a runtime exception:

Unhandled exception. System.PlatformNotSupportedException: Couldn't find a suitable window platform. (GlfwPlatform - not applicable, SdlPlatform - not applicable) https://dotnet.github.io/Silk.NET/docs/hlu/troubleshooting.html
   at Silk.NET.Windowing.Window.Create(WindowOptions options)
   at Tutorial.Program.Main(String[] args)
Exception message

On the linked troubleshooting page it says

Silk.NET should do a good job of copying the appropriate native libraries upon build by default, and will search your PATH for them if not present in the output directory.

I didn't see any native libraries being copied to the output directory. The documentation then says to try putting the native libraries in your project so it copies to the output folder. I was on my way to do that for GLFW when I reread the first statement about "...will search your PATH for them...". I realized that I may not have SDL or GLFW installed! So after some quick searching I found out how to install GLFW (on Pop_OS 20.04, which should work for Ubuntu as well): sudo apt install libglfw3-dev

After a short install time – even as libglwf3-dev brings its dependencies along for the ride – I was ready to try again. I have never been so happy to see a blank window open!

My first window opened using Silk.NET