-
-
Notifications
You must be signed in to change notification settings - Fork 424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libdl.so is not available on many Linux distros, causing crashes on native library load #1492
Comments
Thanks for letting us know. I have looked at the fix and concluded that this isn't an appropriate fix for Silk.NET, namely the try-and-catch method tends to create a poor user experience given that users are encouraged to have first chance exception handling on when debugging their applications. As you have identified that this is working on the newer .NET versions, I don't think we will take any action here. Please use the latest .NET. |
To be clear, upgrading to the latest .NET version is not possible at this time for my use case. I've been looking into Silk.NET to provide bindings for use in the BizHawk project, which is stuck on .NET Framework due to several .NET Framework only dependencies (e.g. OpenTK for OpenAL/OpenGL bindings), so we've been moving away from dependencies one by one by switching them to .NET Standard 2.0, allowing us to easily upgrade when we no longer have .NET Framework dependencies. Considering that most (if not all?) Linux distros seem to just have libdl.so.2, perhaps it'd be fair to just switch the p/invoke to that? |
I would be happy switching exclusively to just |
https://refspecs.linuxfoundation.org/LSB_1.0.0/gLSB/libdl.html Actually, I suspect that practically every Linux distro should have libdl.so.2, otherwise they wouldn't even conform with LSB (which seems to have and still specify libdl.so.2 as the .so name for libdl). So I highly doubt it would cause issues (and for the small fraction of users who can't use new .NET versions and have a Linux distro which does not comply with LSB, which even then at that point I doubt they could use .NET in the first place, they could workaround this with a dllmap hack) (also, other Unix targets wouldn't be affected in reality, as they use the BsdLibraryLoader, which just uses libc) |
Nearly all (or all if only counting LSB conforming) Linux distros have libdl.so.2, and usually don't have a libdl.so symlink unless dev packages are installed. Fixes dotnet#1492
Summary
Many Linux distros do not have libdl.so, rather they only have libdl.so.2. This causes a
DllNotFoundException
when using its native functions.This would only occur when using .NET Framework / .NET Standard, as .NET Core / .NET 5+ just use
System.Runtime.InteropServices.NativeLibrary
instead of P/Invoking libdl directly.According to the loader readme, the code was taken from NativeLibraryLoader, which seems to have this issue fixed already, so it's probably as simple as porting over that fix.
Steps to reproduce
The text was updated successfully, but these errors were encountered: