SteveSandersonMS / dotnet-wasi-sdk

Packages for building .NET projects as standalone WASI-compliant modules
518 stars 36 forks source link

Load platform native library #52

Open Beyley opened 1 year ago

Beyley commented 1 year ago

Is it possible to use DLLImport to call into native libraries? ex.

[DllImport("glfw")]
static extern int glfwInit();

...

glfwInit();

Upon attempting to do it this way causes an error

Unhandled Exception:
System.InvalidProgramException
   at Program.<Main>$(String[] args)

trying to use

var lib = NativeLibrary.Load("libglfw.so");

just causes

Unhandled Exception:
System.DllNotFoundException: 'libglfw.so': ''
   at System.Runtime.InteropServices.NativeLibrary.Load(String libraryPath)
   at Program.<Main>$(String[] args)