SQLitePCL.raw icon indicating copy to clipboard operation
SQLitePCL.raw copied to clipboard

Unity Mono Support?

Open AmirMahdiNassiri opened this issue 5 years ago • 4 comments

First of all many thanks for your amazing libraries. I'm using them in my WPF .Net Core apps as well as Xamarin apps.

Right now I'm trying to import one of my class libraries targeted for .Net Standard 2.0 which uses your libraries and Microsoft.EntityFrameworkCore.Sqlite as well.

I'm getting this error:

System.DllNotFoundException: e_sqlite3 at (wrapper managed-to-native) SQLitePCL.SQLite3Provider_e_sqlite3+NativeMethods.sqlite3_libversion_number() at SQLitePCL.SQLite3Provider_e_sqlite3.SQLitePCL.ISQLite3Provider.sqlite3_libversion_number () at SQLitePCL.raw.SetProvider (SQLitePCL.ISQLite3Provider imp) at SQLitePCL.Batteries_V2.Init ()

I'm assuming that there is no native wrapper for Unity runtime Mono. Is that right?

Is there any way that we can get it set up for use in Unity?

Any help is deeply appreciated.

AmirMahdiNassiri avatar May 23 '20 01:05 AmirMahdiNassiri

Sounds like e_sqlite3.dll isn't getting copied to the output directory. You might need to copy some of the logic from SQLitePCLRaw.lib.e_sqlite3.targets into your project.

bricelam avatar Jul 16 '20 22:07 bricelam

After installing the package with NuGetForUnity, I had to manually include the native assets and specify their platform settings, but I was able to get it working.

image

SQLitePCL.Batteries_V2.Init();
GetComponent<Text>().text = SQLitePCL.raw.sqlite3_libversion().utf8_to_string();

bricelam avatar Jul 27 '20 19:07 bricelam

@bricelam I'd like to replicate what you've done. Would you mind sharing where you download the native assets?

I get:

Exception: Library e_sqlite3 not found
plat: dlopen
suffix: DYLIB
possibilities (2):
    1) /Users/eric/Documents/DialogueEditor/Assets/Packages/SQLitePCLRaw.core.2.1.2/lib/netstandard2.0/runtimes/osx-x64/native/libe_sqlite3.dylib
    2) /Users/eric/Documents/DialogueEditor/Assets/Packages/SQLitePCLRaw.core.2.1.2/lib/netstandard2.0/libe_sqlite3.dylib
dlopen TryLoad: /Users/eric/Documents/DialogueEditor/Assets/Packages/SQLitePCLRaw.core.2.1.2/lib/netstandard2.0/runtimes/osx-x64/native/libe_sqlite3.dylib
dlopen gave: 0
dlopen TryLoad: /Users/eric/Documents/DialogueEditor/Assets/Packages/SQLitePCLRaw.core.2.1.2/lib/netstandard2.0/libe_sqlite3.dylib
dlopen gave: 0
NOT FOUND

SQLitePCL.NativeLibrary.Load (System.String libraryName, System.Reflection.Assembly assy, System.Int32 flags) (at <8a9cf65dcc6542b59d3abc28e58f9815>:0)
SQLitePCL.Batteries_V2.MakeDynamic (System.String name, System.Int32 flags) (at <8a9cf65dcc6542b59d3abc28e58f9815>:0)
SQLitePCL.Batteries_V2.DoDynamic_cdecl (System.String name, System.Int32 flags) (at <8a9cf65dcc6542b59d3abc28e58f9815>:0)
SQLitePCL.Batteries_V2.Init () (at <8a9cf65dcc6542b59d3abc28e58f9815>:0)

Sahasrara avatar Oct 17 '22 02:10 Sahasrara

I think they were downloaded by NuGetForUnity. Make sure you're looking under the SQLitePCL.lib directory. If they're not downloaded, you can download and extract the package from nuget.org (It's just a zip file with .nupkg for its extension.)

bricelam avatar Oct 24 '22 20:10 bricelam