SQLProvider
SQLProvider copied to clipboard
Unable to load shared library 'SQLite.Interop.dll'
Describe the bug I can't get most basic example like https://fsprojects.github.io/SQLProvider/core/sqlite.html working.
To Reproduce Steps to reproduce the behavior:
-
Create new console application.
dotnet new console -lang F# -o SQLite cd SQLite dotnet add package SQLProvider dotnet add package System.Data.SQLite -
Build sqlite-netFx
cd /tmp mkdir sqlite-netFx cd sqlite-netFx wget https://system.data.sqlite.org/downloads/1.0.115.5/sqlite-netFx-full-source-1.0.115.5.zip unzip sqlite-netFx-full-source-1.0.115.5.zip cd Setup sh compile-interop-assembly-debug.sh cp -rf bin/2013/Release/bin ~/github/fsharp_sqlprovider/SQLite/lib -
Add lib to SQLite.fsproj (in ItemGroup)
<None Include="lib/libSQLite.Interop.so"> <CopyToOutputDirectory>Always</CopyToOutputDirectory> </None> -
Copy
northwindEF.dbfrom SQLProvider toSQLite/db -
Add to Program.fs
open System open FSharp.Data.Sql [<Literal>] let connectionString = @"Data Source=" + __SOURCE_DIRECTORY__ + @"/db/northwindEF.db;Version=3;Read Only=false;FailIfMissing=True;" //If System.Data.SQLite.dll is in the location where NuGet places it by default, you don't have to submit the ResolutionPath parameter at all, but you still need to copy the interop libraries as described above. type sql = SqlDataProvider<Common.DatabaseProviderTypes.SQLITE, connectionString, CaseSensitivityChange=Common.CaseSensitivityChange.ORIGINAL, SQLiteLibrary=Common.SQLiteLibrary.SystemDataSQLite> -
Run
dotnet run/home/a/github/fsharp_sqlprovider/SQLite/Program.fs(20,5): error FS3033: The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: Unable to load shared library 'SQLite.Interop.dll' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libSQLite.Interop.dll: cannot open shared object file: No such file or directory [/home/a/github/fsharp_sqlprovider/SQLite/SQLite.fsproj] /home/a/github/fsharp_sqlprovider/SQLite/Program.fs(20,5): error FS3033: The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: Unable to load shared library 'SQLite.Interop.dll' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libSQLite.Interop.dll: cannot open shared object file: No such file or directory [/home/a/github/fsharp_sqlprovider/SQLite/SQLite.fsproj] The build failed. Fix the build errors and run again. -
System information
dotnet --info.NET SDK (reflecting any global.json): Version: 5.0.403 Commit: bf9d168ac2 Runtime Environment: OS Name: ubuntu OS Version: 20.04 OS Platform: Linux RID: ubuntu.20.04-x64 Base Path: /usr/share/dotnet/sdk/5.0.403/ Host (useful for support): Version: 5.0.12 Commit: 7211aa01b3 .NET SDKs installed: 3.1.415 [/usr/share/dotnet/sdk] 5.0.403 [/usr/share/dotnet/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 3.1.21 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.12 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.21 [/usr/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.12 [/usr/share/dotnet/shared/Microsoft.NETCore.App] To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download
Should this work? Is the documentation up to date? Which point am I missing?
Thank you!
You need to set the ResolutionPath when working with SQLite. https://fsprojects.github.io/SQLProvider/core/parameters.html#ResolutionPath
The first thing to check with SQLite is that are you running in x64 or x86 mode, and are your reference library dlls in the resolutionpath for the same x64 or x86.
@Thorium Thank you for the quick reply!
At https://fsprojects.github.io/SQLProvider/core/sqlite.html it is stated:
If System.Data.SQLite.dll is in the location where NuGet places it by default, you don't have to submit the ResolutionPath parameter at all, but you still need to copy the interop libraries as described above.
- Every command I have used is plain vanilla like described above, thus this sentence applies, doesn't it?
- Dotnet info shows
RID: ubuntu.20.04-x64and I haven't specified the cpu in my project file, I guess itsx64then. file lib/libSQLite.Interop.solib/libSQLite.Interop.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=5adfce885200ee6faa387376f310e16059940c50, with debug_info, not stripped
I have tried to get it working under windows with https://github.com/fsprojects/SQLProvider/tree/master/tests/SqlProvider.Core.Tests/SQLite
I had to change the copy path to the dlls:
<Exec Command="xcopy ..\..\..\packages\tests\SQLitePCLRaw.core\lib\netstandard2.0\SQLitePCLRaw.core.dll temp\ /y" />
<Exec Command="xcopy ..\..\..\packages\tests\SQLitePCLRaw.lib.e_sqlite3\runtimes\win10-x64\nativeassets\uap10.0\e_sqlite3.dll temp\ /y" />
<Exec Command="xcopy ..\..\..\packages\tests\SQLitePCLRaw.bundle_green\lib\net461\SQLitePCLRaw.batteries_v2.dll temp\ /y" />
<Exec Command="xcopy ..\..\..\packages\tests\Microsoft.Data.Sqlite.Core\lib\netstandard2.0\Microsoft.Data.Sqlite.dll temp\ /y" />
and I get
C:\Users\User\Documents\github\SQLProvider-master\tests\SqlProvider.Core.Tests\SQLite\Program.fs(25,11): error FS3033: The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: Could not load file or assembly 'SQLitePCLRaw.core, Version=2.0.3.851, Culture=neutral, PublicKeyToken=1488e028ca7ab535' or one of its dependencies. The system cannot find the file specified., Path: C:\Users\User\Documents\github\SQLProvider-master\tests\SqlProvider.Core.Tests\SQLite\temp (You are NOT running on x64.) [C:\Users\User\Documents\github\SQLProvider-master\tests\SqlProvider.Core.Tests\SQLite\SqlProvider.Core.Tests.fsproj]
C:\Users\User\Documents\github\SQLProvider-master\tests\SqlProvider.Core.Tests\SQLite\Program.fs(25,11): error FS3033: The type provider 'FSharp.Data.Sql.SqlTypeProvider' reported an error: Could not load file or assembly 'SQLitePCLRaw.core, Version=2.0.3.851, Culture=neutral, PublicKeyToken=1488e028ca7ab535' or one of its dependencies. The system cannot find the file specified., Path: C:\Users\User\Documents\github\SQLProvider-master\tests\SqlProvider.Core.Tests\SQLite\temp (You are NOT running on x64.) [C:\Users\User\Documents\github\SQLProvider-master\tests\SqlProvider.Core.Tests\SQLite\SqlProvider.Core.Tests.fsproj]
C:\Users\User\Documents\github\SQLProvider-master\tests\SqlProvider.Core.Tests\SQLite\Program.fs(30,18): error FS0039: The type 'Object' does not define the field, constructor or member 'GetDataContext'. [C:\Users\User\Documents\github\SQLProvider-master\tests\SqlProvider.Core.Tests\SQLite\SqlProvider.Core.Tests.fsproj]
C:\Users\User\Documents\github\SQLProvider-master\tests\SqlProvider.Core.Tests\SQLite\Program.fs(33,24): error FS0072: Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved. [C:\Users\User\Documents\github\SQLProvider-master\tests\SqlProvider.Core.Tests\SQLite\SqlProvider.Core.Tests.fsproj]
C:\Users\User\Documents\github\SQLProvider-master\tests\SqlProvider.Core.Tests\SQLite\Program.fs(34,20): error FS0072: Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved. [C:\Users\User\Documents\github\SQLProvider-master\tests\SqlProvider.Core.Tests\SQLite\SqlProvider.Core.Tests.fsproj]
The build failed. Fix the build errors and run again.
I guess Microsoft.Data.Sqlite.dll is x86. How do I get the x64 version?