dart-archive / ffi

Utilities for working with Foreign Function Interface (FFI) code
https://pub.dev/packages/ffi
BSD 3-Clause "New" or "Revised" License
156 stars 32 forks source link

Can't load 32bit DLL #152

Closed soufiane-larbi closed 2 years ago

soufiane-larbi commented 2 years ago

Hi Guys,

I am working on flutter windows app. I've no problem when i load win x64 DLL but 32bit dll throw me 193 error. Please suggest any solution, the dll is for Zkteco attendance machine and no 64 dll was provided.

Thanks.


Dart SDK version: 2.17.1 (stable) (Tue May 17 17:58:21 2022 +0000) on "windows_x64"

final dll = DynamicLibrary.open("zkemkeeper.dll");

[ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: Invalid argument(s): Failed to load dynamic library 'zkemkeeper.dll': error code 193

0 _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:12:43)

https://github.com/dart-lang/samples/pull/1 new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:23:12) https://github.com/dart-lang/samples/pull/2 main package:mgx/main.dart:11 https://github.com/dart-lang/samples/pull/3 _runMainZoned.. (dart:ui/hooks.dart:130:25) https://github.com/dart-lang/samples/pull/4 _rootRun (dart:async/zone.dart:1426:13) https://github.com/dart-lang/samples/issues/5 _CustomZone.run (dart:async/zone.dart:1328:19) https://github.com/dart-lang/samples/issues/6 _runZoned (dart:async/zone.dart:1861:10) https://github.com/dart-lang/samples/issues/7 runZonedGuarded (dart:async/zone.dart:1849:12) https://github.com/dart-lang/samples/pull/8 _runMainZoned. (dart:ui/hooks.dart:126:5)

dcharkes commented 2 years ago

It is not possible to load a 32 bit DLL in a 64 bit executable.

I don't believe Flutter desktop Windows can compile to 32 bit.

If you really need to use a 32 bit dll, I suggest building a separate 32 bit C commandline application that uses the 32 bit dll, and then use Process.run to invoke that from your Flutter app.

soufiane-larbi commented 2 years ago

Thanks for you reply, i'll try it.