Brumd
Static linking of `.lib`/`.a` file not working
I'm using Native AOT (+ .NET 8) and I want to statically link my static lib from another language so I can call it from C# while still only distributing a single complete file.
It compiles fine but for some reason I keep getting runtime errors of C# looking for a shared object? It says
Unhandled exception. System.DllNotFoundException: Unable to load shared library 'mylib' or one of its dependencies
C#:
CSProj:
For context, the file is stored in the lib
folder inside project directory.
Why is it trying to load the DLL? It's complaining how it can't find mylib.so
/libmylib.so
/mylib
/libmylib
, when of course they don't exist because it shouldn't need them?
I've been trying to follow various resources like:
- https://learn.microsoft.com/en-us/dotnet/core/deploying/native-aot/interop
- https://github.com/dotnet/runtime/issues/89044
- https://github.com/sneusse/aot-static-example3 replies