Skip to content

Linux ARM64 build with AoT compile: Unable to load shared library 'e_sqlite3' #656

@devedse

Description

@devedse

I'm currently trying to create an application that uses Dapper to connect to an SQLite database. I'm compiling it with AoT and running it on a Raspberry PI.

I created a Dockerfile that compiles the application based on the runtime it's running on.

For Linux x64 this works fine, but for ARM64 it shows the following exception:

fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[1]
      An unhandled exception has occurred while executing the request.
      System.TypeInitializationException: A type initializer threw an exception. To determine which type, inspect the InnerException's StackTrace property.
       ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
       ---> System.DllNotFoundException: Unable to load shared library 'e_sqlite3' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable:
      /app/e_sqlite3.so: cannot open shared object file: No such file or directory
      /app/libe_sqlite3.so: cannot open shared object file: No such file or directory
      /app/e_sqlite3: cannot open shared object file: No such file or directory
      /app/libe_sqlite3: cannot open shared object file: No such file or directory

         at System.Runtime.InteropServices.NativeLibrary.LoadLibErrorTracker.Throw(String) + 0x50
         at Internal.Runtime.CompilerHelpers.InteropHelpers.FixupModuleCell(InteropHelpers.ModuleFixupCell*) + 0x140
         at Internal.Runtime.CompilerHelpers.InteropHelpers.ResolvePInvokeSlow(InteropHelpers.MethodFixupCell*) + 0x40
         at SQLitePCL.SQLite3Provider_e_sqlite3.NativeMethods.sqlite3_libversion_number() + 0x38
         at SQLitePCL.raw.SetProvider(ISQLite3Provider) + 0x18
         at DevePXEBoot!<BaseAddress>+0x18d29cc
         at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) + 0x10c
         --- End of inner exception stack trace ---
         at System.Reflection.DynamicInvokeInfo.Invoke(Object, IntPtr, Object[], BinderBundle, Boolean) + 0x1ec
         at Internal.Reflection.Execution.MethodInvokers.StaticMethodInvoker.Invoke(Object, Object[], BinderBundle, Boolean) + 0x2c
         at System.Reflection.Runtime.MethodInfos.RuntimeMethodInfo.Invoke(Object, BindingFlags, Binder, Object[], CultureInfo) + 0x68
         at Microsoft.Data.Sqlite.SqliteConnection..cctor() + 0x13c
         at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext*) + 0xb4
         --- End of inner exception stack trace ---
         at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext*) + 0x15c
         at System.Runtime.CompilerServices.ClassConstructorRunner.CheckStaticClassConstructionReturnNonGCStaticBase(StaticClassConstructionContext*, IntPtr) + 0x14
         at Microsoft.Data.Sqlite.SqliteConnection..ctor(String) + 0x64
         at DevePXEBoot.Db.DapperRepositories.PxeRequestLogRepositoryDapper.<GetRecentRequestsAsync>d__3.MoveNext() + 0x68
      --- End of stack trace from previous location ---
         at DevePXEBoot.Services.PxeRequestLogService.<GetRecentRequestsAsync>d__5.MoveNext() + 0x5c
      --- End of stack trace from previous location ---
         at DevePXEBoot.Endpoints.PxeRequestsEndpoints.<>c.<<MapPxeRequestsEndpoints>b__0_0>d.MoveNext() + 0x58
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Http.Generated.<GeneratedRouteBuilderExtensions_g>F36AD9C9E95CB886BBE5BF788763E2D6E57F347622DE9A7096DEE1A210EEE005A__GeneratedRouteBuilderExtensionsCore.<>c__DisplayClass30_0.<<MapGet25>g__RequestHandler|5>d.MoveNext() + 0xd8
      --- End of stack trace from previous location ---
         at DevePXEBoot.Middleware.BootFileTemplateReplacementMiddleware.<InvokeAsync>d__3.MoveNext() + 0x13c
      --- End of stack trace from previous location ---
         at DevePXEBoot.Middleware.PxeRequestLoggingMiddleware.<InvokeAsync>d__3.MoveNext() + 0x90
      --- End of stack trace from previous location ---
         at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddlewareImpl.<<Invoke>g__Awaited|10_0>d.MoveNext() + 0xb0

So it's effectively looking for 4 files it seems:

/app/e_sqlite3.so: cannot open shared object file: No such file or directory
/app/libe_sqlite3.so: cannot open shared object file: No such file or directory
/app/e_sqlite3: cannot open shared object file: No such file or directory
/app/libe_sqlite3: cannot open shared object file: No such file or directory

The weird thing is though that the /app/libe_sqlite3.so file actually exists in that folder (inside the container):

pi@dockerpi:~/dockercomposers/DevePXEBoot $ docker exec -it devepxeboot /bin/bash
root@677da0ceb694:/app# ls
BuildHost-net472  BuildHost-netcore  DevePXEBoot  DevePXEBoot.Migrator  DevePXEBoot.staticwebassets.endpoints.json  appsettings.json  libe_sqlite3.so  liblzfse.so  scripts  wwwroot

So I'm really unsure where this is going wrong and whether this is even an issue related to this package. So please, if it is not, could someone close this issue and point me to the right place to ask for help 😄 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions