Fix for Linux not knowing how to load versioned libraries.
@@ -36,10 +36,21 @@ namespace StereoKit
return false;
}
+ static bool LoadUnix(string arch)
+ {
+ try
+ {
+ return LoadUnix1(arch);
+ }
+ catch (DllNotFoundException)
+ {
+ return LoadUnix2(arch);
+ }
+ }
[DllImport("dl", CharSet = CharSet.Ansi)]
static extern IntPtr dlopen(string fileName, int flags);
- static bool LoadUnix(string arch)
+ static bool LoadUnix1(string arch)
{
const int RTLD_NOW = 2;
if (dlopen($"./runtimes/linux-{arch}/native/libStereoKitC.so", RTLD_NOW) != IntPtr.Zero) return true;
@@ -47,5 +58,17 @@ namespace StereoKit
if (dlopen("libStereoKitC.so", RTLD_NOW) != IntPtr.Zero) return true;
return false;
}
+
+ // A hack to support
+ [DllImport("libdl.so.2", CharSet = CharSet.Ansi, EntryPoint = "dlopen")]
+ static extern IntPtr dlopen2(string fileName, int flags);
+ static bool LoadUnix2(string arch)
+ {
+ const int RTLD_NOW = 2;
+ if (dlopen2($"./runtimes/linux-{arch}/native/libStereoKitC.so", RTLD_NOW) != IntPtr.Zero) return true;
+ if (dlopen2($"{AppDomain.CurrentDomain.BaseDirectory}/runtimes/linux-{arch}/native/libStereoKitC.so", RTLD_NOW) != IntPtr.Zero) return true;
+ if (dlopen2("libStereoKitC.so", RTLD_NOW) != IntPtr.Zero) return true;
+ return false;
+ }
}
}
