libSQLite.Interop not found Mac OS | M1
Asked Answered
A

2

8

I am using dotnet 6 on a M1 Pro, and am struggling to use the SQLite-Package.

System.DllNotFoundException: Unable to load shared library 'SQLite.Interop.dll' or one of its dependencies.

This is the error that is thrown, whenever I try to run the application. Building however works fine.

Addlebrained answered 10/1, 2022 at 10:9 Comment(0)
L
9

As a workaround to sqlite not yet targeting arm64, you can use the .net 6 x64 architecture.

  • Install .net 6 x64 from here.
  • Configure your IDE (or terminal) to use .net x64. This will vary by IDE, but in Rider:
    • Press CMD , to open preferences
    • Navigate to "Toolset and build" section
    • Change the .NET CLI executable path to /usr/local/share/dotnet/x64/dotnet

enter image description here

Lorianne answered 27/7, 2022 at 19:34 Comment(1)
This is what solved it for me! Thank you :)Quad
M
8

I managed to fix this issue by building both the Interop.dll file and the dotnet library file on my M1 macbook from source. Only building the Interop.dll results in an EntrypointNotFoundException. To build the library, download the source code from the SQLite website, as of writing this is the file sqlite-netFx-source-1.0.115.5.zip. Extract it and run the file Setup/compile-interop-assembly-release.sh. To build the Library, run dotnet build -c Release in the System.Data.SQLite directory. Your interop file will be in bin/2013/Release/bin. I symlinked it to /usr/local/lib/libSQLite.Interop.dll, but you can also copy it into your project directory as libSQLite.Interop.dll. Now add a reference to bin/NetStandard21/ReleaseNetStandard21/bin/netstandard2.1/System.Data.SQLite.dll into your project and it should run fine.

Update: It also runs fine using the outdated version 1.0.115 directly from NuGet as of writing.

Madura answered 7/3, 2022 at 21:3 Comment(3)
I also had to modify the compile-interop-assembly-release.sh with ` gccflags="-arch x86_64 -arch arm64"` instead of just ` gccflags="-arch x86_64"` Anyways, thanks a lot for your answer, could not find any solutions to this :)Telega
These steps worked great for me on 1.0.116 on a linux arm64 ubuntu docker container running on an M1 mac. A few notes: In the System.Data.SQLite dir, I had to run dotnet build -c Release System.Data.SQLite.NetStandard21.csproj (i.e., specifying the project); I ran the following to install the interop lib: sudo cp ./sqlite-source/bin/2013/Release/bin/SQLite.Interop.dll /usr/lib/libSQLite.Interop.dll; I had to remove the ProjectReference to System.Data.SQLite.Core in my project, as well as adding the Reference to the compiled System.Data.SQLite.dll.Contraoctave
Could someone who managed to compile for arm64 share the resulting dlls? @teocomi?Sidle

© 2022 - 2024 — McMap. All rights reserved.