'Flutter ffi failed to open dynamic library
I'm trying to use the flutter ffi to port over my c/c++ code but it's unable to open the dynamic library it needs to be able to work(I'm on windows)
import 'dart:ffi';
import 'dart:io' show Directory, Platform;
import 'package:ffi/ffi.dart';
import 'package:path/path.dart' as path;
typedef ValidNative = Bool Function(Pointer<Utf8> name, Pointer<Utf8> password);
typedef valid = bool Function(Pointer<Utf8> name, Pointer<Utf8> password);
void main() {
// Open the dynamic library
var libraryPath = path.join(Directory.current.path, 'src', 'ye.so');
if (Platform.isMacOS) {
libraryPath = path.join(Directory.current.path, 'src', 'ye.dylib');
}
if (Platform.isWindows) {
libraryPath = path.join(Directory.current.path, 'src', 'dll');
}
final dylib = DynamicLibrary.open(libraryPath);
final valid Valid = dylib.lookupFunction<ValidNative, valid>('valid');
var thi = Valid('Admin'.toNativeUtf8(), 'password'.toNativeUtf8());
}
does anyone know how I could fix this and get it to open the library(in my case the DLL file)? Any help would be appreciated!
edit_ here's some information the error code provided:
#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 main (package:zenwall/ffi_bridge.dart:19:32)
#3 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:19)
#4 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|