Skip to content

Commit

Permalink
use libdl.so.2 instead of libdl.so for linux
Browse files Browse the repository at this point in the history
This should fix builds on ubuntu-22.04.
- see https://stackoverflow.com/a/75855054
- see ied206/Joveler.DynLoader#1 for other dotnet library with the same issue
  • Loading branch information
hoffmann-stefan committed Apr 20, 2023
1 parent eaea459 commit d3b41ce
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions rcldotnet_common/DllLoadUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ public class DllLoadUtilsFactory {
[DllImport ("kernel32.dll", EntryPoint = "FreeLibrary", SetLastError = true, ExactSpelling = true)]
private static extern int FreeLibraryDesktop (IntPtr handle);

[DllImport ("libdl.so", EntryPoint = "dlopen")]
[DllImport ("libdl.so.2", EntryPoint = "dlopen")]
private static extern IntPtr dlopen_unix (String fileName, int flags);

[DllImport ("libdl.so", EntryPoint = "dlclose")]
[DllImport ("libdl.so.2", EntryPoint = "dlclose")]
private static extern int dlclose_unix (IntPtr handle);

[DllImport ("libdl.dylib", EntryPoint = "dlopen")]
Expand Down Expand Up @@ -106,7 +106,7 @@ private static bool IsWindowsDesktop () {

private static bool IsUnix () {
try {
IntPtr ptr = dlopen_unix ("libdl.so", RTLD_NOW);
IntPtr ptr = dlopen_unix ("libdl.so.2", RTLD_NOW);
dlclose_unix (ptr);
return true;
} catch (TypeLoadException) {
Expand Down Expand Up @@ -205,16 +205,16 @@ IntPtr DllLoadUtils.LoadLibrary (string fileName) {

internal class DllLoadUtilsUnix : DllLoadUtils {

[DllImport ("libdl.so", ExactSpelling = true)]
[DllImport ("libdl.so.2", ExactSpelling = true)]
private static extern IntPtr dlopen (String fileName, int flags);

[DllImport ("libdl.so", ExactSpelling = true)]
[DllImport ("libdl.so.2", ExactSpelling = true)]
private static extern IntPtr dlsym (IntPtr handle, String symbol);

[DllImport ("libdl.so", ExactSpelling = true)]
[DllImport ("libdl.so.2", ExactSpelling = true)]
private static extern int dlclose (IntPtr handle);

[DllImport ("libdl.so", ExactSpelling = true)]
[DllImport ("libdl.so.2", ExactSpelling = true)]
private static extern IntPtr dlerror ();

const int RTLD_NOW = 2;
Expand Down

0 comments on commit d3b41ce

Please sign in to comment.