7

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.

Linsane
  • 338
  • 4
  • 16

3 Answers3

7

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.

zotan
  • 71
  • 4
  • 2
    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 :) – teocomi Sep 11 '22 at 10:20
  • 4
    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`. – sam256 Oct 14 '22 at 09:01
  • Could someone who managed to compile for arm64 share the resulting dlls? @teocomi? – Leon V Sep 03 '23 at 04:32
6

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

Noel
  • 3,288
  • 1
  • 23
  • 42
0

I have the same problem. If I check in "bin/Debug/net6.0/runtimes", there is a folder for every architecture, and I see "SQLite.Interop.dll" in each and every one of them. The problem is, the only architectures that are available are "linux-x64, osx-x64, unix, win, win-arm64, win-x64, win-x86". So we're badly missing "macos-arm64". I'd be happy to use a docker dev container, but neither is "linux-arm64" there. Not sure what to do other than wait (for implementation). What is even more strange is that I have tried in Windows11 as a virtual machine on my Mac, and it does not resolve the win-arm64 dll neither. Sorry it's no answer, I'm just posting it here, so that it might trigger someone for a solution.

ouflak
  • 2,458
  • 10
  • 44
  • 49
bexa
  • 11
  • 1