System.DllNotFoundException: Unable to load shared library 'LiteCore

Running on …

Couchbase Lite .Net 3.0.0
RPi4 aarch64 (Linux / Debian)

Unhandled exception. System.TypeInitializationException: The type initializer for ‘Couchbase.Lite.Database’ threw an exception.
—> System.DllNotFoundException: Unable to load shared library ‘LiteCore’ or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libLiteCore: cannot open shared object file: No such file or directory
at LiteCore.Interop.Native.c4log_getDomain(Byte* name, Boolean create)
at Couchbase.Lite.Logging.FileLogger.SetupDomainObjects()
at Couchbase.Lite.Logging.FileLogger…ctor()
at Couchbase.Lite.Logging.Log…ctor()
at Couchbase.Lite.Database…cctor()
— End of inner exception stack trace —
at Couchbase.Lite.Database…ctor(String name, DatabaseConfiguration configuration)
at NetClient.Program.Main(String args) in /home/pi/development/net-client/Program.cs:line 16

    using System;
    using System.IO;
    using Couchbase.Lite;
    using Couchbase.Lite.Query;
    using Couchbase.Lite.Sync;
    using Couchbase.Lite.Support;

namespace NetClient
{
     class Program
     {
        static void Main(string[] args)
        {
            // Couchbase.Lite.Support.Activate();
            // Create or open database
            var database = new Database("mydb");
            
            // Create replicator to push and pull changes to and from the cloud
            var targetEndpoint = new URLEndpoint(new Uri("wss://...."));
            var replConfig = new ReplicatorConfiguration(database, targetEndpoint);
            
            // Add authentication
            replConfig.Authenticator = new BasicAuthenticator("...", "...");
            
            // Optionally, Create replicator (make sure to add an instance or static variable
            // named _Replicator)
            var _Replicator = new Replicator(replConfig);
            _Replicator.AddChangeListener((sender, args) =>
            {
            if (args.Status.Error != null)
            {
                Console.WriteLine($"Error :: {args.Status.Error}");
            }
            });
            
            // Start replicator
            _Replicator.Start();
        }
    }
}

The simple and disappointing answer here is that this is not a supported platform. This platform is on the radar for a future release, but as of now this is as far as you will get.

However, you may be interested to know that the C SDK will function on this platform and there are apt packages for both raspbian 9 and raspios 10.

Hey @borrrden, I was curious if the the .Net API is expected to work in aarch64 as of December 2023? I’m having a similar / same error as OP using version “3.1.1” of Couchbase Lite .Net on an NVidia Jetson.

I’m sorry to say that the answer has not changed.

Thanks for the quick reply @borrrden! That’s a shame, but glad there is at least some way to work with CBLite in aarch64, by using C.

What actually needs to be done to make the .NET API work in aarch64? Is it something I could contribute myself?

The biggest hurdle in having this is the testing burden that it generates, and not anything technical. Technically it will work as long as you have built LiteCore for aarch64 and included that into the correct runtimes folder in Couchase.Lite.Support.NetDesktop. The very unfortunate part about that is the LiteCore license doesn’t allow commercial use for a scenario like this.

Side note: The story is a lot more muddy for arm 32-bit which has all kinds of specialized flags regarding CPU extensions, endianness, floating point support, it’s basically a lego set whereas aarch64 standardized a lot so that you don’t need a thousand different builds, or an ancient non optimized arm machine language variant.

1 Like

That makes a lot of sense. Thanks for the context. I’ll proceed with using the C API for now.