Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong architecture when NativeLibrary.Load cause Library e_sqlite3 not found #584

Open
okt-wang opened this issue Jan 23, 2024 · 1 comment

Comments

@okt-wang
Copy link

  • What version of SQLitePCLRaw are you using?
    2.1.7

  • If you are using one of the SQLitePCLRaw bundle packages, which one?
    bundle_e_sqlite3

  • What platform are you running on? What operating system? Which version? What CPU?
    Embedd Linux arm64, arm-cortex a53, run with mono 6.12.0.200

  • What target framework are you building for?
    .net framework 4.8.1

  • Are you on .NET Framework or the newer stuff (.NET Core, .NET 5+, etc)?
    .net framework 4.8.1

  • Are you using the command line, or an IDE? Which IDE? Which version of that IDE?
    Visual Studio 2019

  • Is this problem something that just started happening? For example, were things working well for you and then you updated something and then the problem showed up? What changed?

  • What is the exact error message you are seeing when the problem happens?
    My OS system is arm64, but it want to load linux-x64 version of libe_sqlite3.so, and show error of Library e_sqlite3 not found

1 Unhandled Exception: 
2 System.TypeInitializationException: The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Exception: Library e_sqlite3 not found 
3 plat: dlopen 
4 suffix: SO 
5 possibilities (2): 
6     1) /run/media/mmcblk0p5/TestDB/sqlite/memory/test/runtimes/linux-x64/native/libe_sqlite3.so 
7     2) /run/media/mmcblk0p5/TestDB/sqlite/memory/test/libe_sqlite3.so 
8 dlopen TryLoad: /run/media/mmcblk0p5/TestDB/sqlite/memory/test/runtimes/linux-x64/native/libe_sqlite3.so 
9 thrown: System.DllNotFoundException: dl 
10   at (wrapper managed-to-native) SQLitePCL.NativeLibrary+NativeLib_dlopen.dlopen(string,int) 
11   at SQLitePCL.NativeLibrary.TryLoad (System.String name, SQLitePCL.NativeLibrary+Loader plat, System.Action`1[T] log, System.IntPtr& h) [0x00069] in <1c82ecb939124f42b01caceba8a570df>:0
  • Are you using PackageReference or packages.config?
    packages.config

  • If you are using mobile platforms, are you on classic/legacy Xamarin or on .NET 6 and higher?
    No

  • Sometimes other packages using SQLitePCLRaw cause problems when they are mixed together. What other packages are you including in your project?
    Only Microsoft.Data.Sqlite

image

How can we reproduce the problem you are seeing? Your issue will get attention much faster if you attach a minimal reproduction sample project.

@ericsink
Copy link
Owner

My first reaction to this issue is to say that Mono and packages.config are on my list of things I'm not sure I want to support at this point.

That said, if the e_sqlite3 native binary is compatible with your OS, I suspect this could be made to work by initializing the provider manually instead of using a bundle.

Rough steps:

Get rid of bundle_e_sqlite3 and provider.dynamic_cdecl.

Keep SQLitePCLRaw.core and SQLitePCLRaw.lib.e_sqlite3

Add SQLitePCLRaw.provider_e_sqlite3

Add code to initialize things, something like this:

SQLitePCL.raw.SetProvider(new SQLitePCL.SQLite3Provider_e_sqlite3());

What I don't know is whether the proper libe_sqlite3.so will end up in "the right place" using whatever building tooling you've got. I'll stay pessimistic on that for the moment, but if you find the file and copy it to your build output directory, it should/might work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants