objectbox / objectbox-dart

Flutter database for super-fast Dart object persistence
https://docs.objectbox.io/getting-started
Apache License 2.0
1.04k stars 120 forks source link

windows 11 : Invalid argument(s): Failed to load dynamic library 'lib/objectbox.dll': error code 1497360904 #323

Closed gcxfd closed 2 years ago

gcxfd commented 3 years ago

windows 11 Dart SDK version: 2.15.0-208.0.dev (dev) (Mon Oct 11 22:12:57 2021 -0700) on "windows_x64" ( use choco install dart-sdk --pre -y install ) objectbox dart latest

final store = openStore();     

error

Unhandled exception:
Invalid argument(s): Failed to load dynamic library 'lib/objectbox.dll': error code 1497360904
#0      _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:12:43)
#1      new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:23:12)
#2      _tryObjectBoxLibFile (package:objectbox/src/native/bindings/bindings.dart:56:27)
#3      loadObjectBoxLib (package:objectbox/src/native/bindings/bindings.dart:66:12)
#4      C (package:objectbox/src/native/bindings/bindings.dart:84:27)
#5      C (package:objectbox/src/native/bindings/bindings.dart)
#6      new Model (package:objectbox/src/native/model.dart:19:31)
#7      new Store (package:objectbox/src/native/store.dart:105:21)
#8      openStore (package:rmw/objectbox.g.dart:45:5)
#9      init (package:rmw/init.dart:59:17)
<asynchronous suspension>
#10     main (file:///C:/Users/z/git/rmw/bin/rmw.dart:29:3)
<asynchronous suspension>
greenrobot-team commented 3 years ago

Thanks. Assuming this is a Dart only project? Did you install objectbox-c as noted at https://github.com/objectbox/objectbox-dart/blob/main/objectbox/README.md#dart-native (or also at https://docs.objectbox.io/getting-started under the Dart tab)?

gcxfd commented 3 years ago

yes i installed, see the image below and I run dart run build_runner build in windows can generate objectbox.g.dart and I test code in mac and linux , it runs ok

image

gcxfd commented 3 years ago

$ sha256sum.exe lib/objectbox.dll 7296135050c481940f00bfac6e7d5637f9b5ac9b40f4c894a548c15ac7485af0 *lib/objectbox.dll

greenrobot-team commented 3 years ago

Works for me using the same file, also inside a lib subfolder. Though I am on Windows 10 64-bit.

The returned error codes are also unexpected and do not lead to any useful info.

Can you try to run the benchmark app inside this repo (it's Dart only), e.g. inside the benchmark folder run dart run bin/read.dart? Then we can be sure it isn't an issue with your code or setup.

richard457 commented 2 years ago

This is also happening here https://github.com/objectbox/objectbox-dart/issues/346 on android @greenrobot-team

greenrobot-team commented 2 years ago

@richard457 The error message in #346 is completely different. Doubt this is related.

greenrobot-team commented 2 years ago

Closing because this issue is missing details. Feel free to comment with additional details and we can re-open it.

claudiu-bele commented 2 years ago

Slightly unrelated to objectbox but windows .dlls, I encountered a similar issue with another number trying to load a .dll in production builds

Failed to load dynamic library 'win_x64/sqlite3.dll': error code 1329587768 

Solution: place .dll in root folder and remove the lib from the path, like

DynamicLibrary _openOnWindows() {
  final corePath = 'sqlite3.dll';
  return DynamicLibrary.open(corePath);
}

I build the apps with hover, msix has the same issues