Updating loading mechanism of native libdl in OpenGL.NET

Hi there 👋🏼

I am trying to get the Nu engine to run. It depends on OpenGL.NET, which is written in C#.

I am a F# developer myself, so please consider that in contrast to my obvious ignorance. 😄

So: First, we have to understand that .NET 8 changed the way they load native libraries.

Great, since it's now abstracted across platforms. However, I am new to C#, and the API documentation lets me a bit in the dark. Probably just me. So, API documentation.

This is the code in question:

#if NETCORE

    [DllImport("dl")]
    public static extern IntPtr dlopen(string filename, int flags);

    [DllImport("dl")]
    public static extern IntPtr dlsym(IntPtr handle, string symbol);

#else

    [DllImport("dl")]
    public static extern IntPtr dlopen([MarshalAs(UnmanagedType.LPTStr)] string filename, int flags);

    [DllImport("dl")]
    public static extern IntPtr dlsym(IntPtr handle, [MarshalAs(UnmanagedType.LPTStr)] string symbol);

#endif

    [DllImport("dl")]
    public static extern string dlerror();    }


Here on Github.

Now my question number 1:

I am confused about the libraryPath. Lots of distros, and macOS as well, seem to have different paths.
And question number 2, if somebody wants to be particularly nice to me:

Could you show me how to use the syntax? 🥺

Is it just public static IntPtr Load(string libdl.so.2); without an attribute?
Was this page helpful?