Search code examples
linuxbrowseravaloniacefglue

CefGlue on Linux: Unable to load shared library 'libcef' or one of its dependencies


I want to run a browser on linux based on Xilium.CefGlue.Avalonia. I created a Project according to the Avalonia Officail Page on linux. The Project builds and runs fine. Now when I create a Browser-variable (var browser = new AvaloniaCEfBrowser()) in the MainWindow.axaml.cs constructor, the project compile fine but it doesn't run on Linux (it runs only in windows) and throws the following error:

Unhandled exception. System.DllNotFoundException: Unable to load shared library 'libcef' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibcef: cannot open shared object file: No such file or directory
   at Xilium.CefGlue.Interop.libcef.api_hash(Int32 entry)
   ...

MainWindow.axaml.cs:

using Avalonia.Controls;
using Xilium.CefGlue.Avalonia;


namespace Test5
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            var browser = new AvaloniaCefBrowser();
        }
    }
}

I downloaded the Cef binaries here and copied the libcef.so file to the bin of the my Project. then I got the following error:

   Unhandled exception. System.IO.FileNotFoundException: Unable to find SubProcess. Probed locations: /home/cdejon/Dokumente/AvaloniaLinux/bin/Debug/net6.0/Xilium.CefGlue.BrowserProcess
/home/cdejon/Dokumente/AvaloniaLinux/bin/Debug/net6.0/CefGlueBrowserProcess/Xilium.CefGlue.BrowserProcess
/home/cdejon/Dokumente/AvaloniaLinux/bin/Debug/net6.0/Xilium.CefGlue.BrowserProcess
/home/cdejon/Dokumente/AvaloniaLinux/bin/Debug/net6.0/CefGlueBrowserProcess/Xilium.CefGlue.BrowserProcess
   at Xilium.CefGlue.Common.CefRuntimeLoader.InternalInitialize(CefSettings settings, KeyValuePair`2[] flags, CustomScheme[] customSchemes, BrowserProcessHandler browserProcessHandler)
   at Xilium.CefGlue.Common.CefRuntimeLoader.Load(BrowserProcessHandler browserProcessHandler)
   at Xilium.CefGlue.Common.BaseCefBrowser..ctor()
   at Xilium.CefGlue.Avalonia.AvaloniaCefBrowser..ctor()
   at AvaloniaLinux.MainWindow..ctor() in /home/cdejon/Dokumente/AvaloniaLinux/MainWindow.axaml.cs:line 11
   at AvaloniaLinux.App.OnFrameworkInitializationCompleted() in /home/cdejon/Dokumente/AvaloniaLinux/App.axaml.cs:line 18
   at Avalonia.Controls.AppBuilderBase`1.Setup() in /_/src/Avalonia.Controls/AppBuilderBase.cs:line 312
   at Avalonia.Controls.AppBuilderBase`1.SetupWithLifetime(IApplicationLifetime lifetime) in /_/src/Avalonia.Controls/AppBuilderBase.cs:line 179
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime[T](T builder, String[] args, ShutdownMode shutdownMode) in /_/src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs:line 208
   at AvaloniaLinux.Program.Main(String[] args) in /home/cdejon/Dokumente/AvaloniaLinux/Program.cs:line 12

Can anyone help me please? I couldn't find any working answer on google or here on stackoverflow.

  1. Stackoverflow 1 have only dead links and no answers.
  2. Stackoverflow 2 is only for Windows

Solution

  • From CefGlue readme:

    The Avalonia implementation runs on Windows and macOS. Linux is not supported yet.