stanoddly / DotnetRaylibWasm

Prototype for .NET 7 with Raylib compiled into WebAssembly (wasm)
MIT License
62 stars 8 forks source link

DllImport requires "libraylib" instead of the usual "raylib" #2

Closed stanoddly closed 1 year ago

stanoddly commented 2 years ago

Raylib-csTo call a native library DllImport attribute is used. This attribute expect a name of the library, however the name "raylib" from Raylib-CS doesn't work, the web page fails with:

dotnet.js:2167 System.DllNotFoundException: raylib

I found that unexpectedly the "lib" prefix is required, even though DllImport's name resolution should be able to handle the prefix just fine. The only official information I found is from (Mono docs)[https://www.mono-project.com/docs/advanced/pinvoke/#library-names]) though.

So instead of "raylib, "libraylib is used in the code.

        /// <summary>
        /// Used by DllImport to load the native library
        /// </summary>
        public const string nativeLibName = "raylib";

This is quite weird behavior and it would require some workarounds, so preferably we need to understand what's going on.

stanoddly commented 1 year ago

There seems to be an easy workaround for that. Simply rename libraylib.a to raylib.a and we're done 😅

Inspired by @anggape's simple solution: https://github.com/anggape/raylib-cs-wasm/blob/b6539a640c65a840924be3784b8d99636b5eb5a5/.github/workflows/gh-pages.yml#L29