diff --git a/Ryujinx.Ava/Ryujinx.Ava.csproj b/Ryujinx.Ava/Ryujinx.Ava.csproj
index 3b4d8cf02a..d36fa62983 100644
--- a/Ryujinx.Ava/Ryujinx.Ava.csproj
+++ b/Ryujinx.Ava/Ryujinx.Ava.csproj
@@ -36,7 +36,7 @@
-
+
diff --git a/Ryujinx/Program.cs b/Ryujinx/Program.cs
index a91f9aa521..be790a48f5 100644
--- a/Ryujinx/Program.cs
+++ b/Ryujinx/Program.cs
@@ -29,7 +29,11 @@ namespace Ryujinx
public static string ConfigurationPath { get; set; }
- [DllImport("libX11")]
+ public static string CommandLineProfile { get; set; }
+
+ private const string X11LibraryName = "libX11";
+
+ [DllImport(X11LibraryName)]
private extern static int XInitThreads();
[DllImport("user32.dll", SetLastError = true)]
@@ -37,6 +41,30 @@ namespace Ryujinx
private const uint MB_ICONWARNING = 0x30;
+ static Program()
+ {
+ if (OperatingSystem.IsLinux())
+ {
+ NativeLibrary.SetDllImportResolver(typeof(Program).Assembly, (name, assembly, path) =>
+ {
+ if (name != X11LibraryName)
+ {
+ return IntPtr.Zero;
+ }
+
+ if (!NativeLibrary.TryLoad("libX11.so.6", assembly, path, out IntPtr result))
+ {
+ if (!NativeLibrary.TryLoad("libX11.so", assembly, path, out result))
+ {
+ return IntPtr.Zero;
+ }
+ }
+
+ return result;
+ });
+ }
+ }
+
static void Main(string[] args)
{
Version = ReleaseInformations.GetVersion();
diff --git a/Ryujinx/Ryujinx.csproj b/Ryujinx/Ryujinx.csproj
index 23f5d15595..58b1555cff 100644
--- a/Ryujinx/Ryujinx.csproj
+++ b/Ryujinx/Ryujinx.csproj
@@ -25,7 +25,7 @@
-
+