gtbluesky / onnxruntime_flutter

A flutter plugin for OnnxRuntime provides an easy, flexible, and fast Dart API to integrate Onnx models in flutter apps across mobile and desktop platforms.
MIT License
68 stars 12 forks source link

Failed to get symbol RegisterCustomOps with error: dlsym(0xbe91bda0, RegisterCustomOps): symbol not found #23

Open saddemYassin opened 4 months ago

saddemYassin commented 4 months ago

Reproduction

  1. Fork the onnxruntime_flutter
  2. Go to lib/src/ort_session.dart
  3. Inside the OrtSessionOptions class ligne 242
  4. Add the registerCustomOpsLibrary methode void registerCustomOpsLibrary(String libPath) { final ppv = calloc<ffi.Pointer<ffi.Void>>(); final statusPtr = OrtEnv.instance.ortApiPtr.ref.RegisterCustomOpsLibrary .asFunction< bg.OrtStatusPtr Function( ffi.Pointer<bg.OrtSessionOptions>, ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Pointer<ffi.Void>>)>()(_ptr, libPath.toNativeUtf8().cast<ffi.Char>(), ppv); OrtStatus.checkOrtStatus(statusPtr); }
  5. Add onnxruntime_extenciens in the example/android android dependency inside app/build.gradle. dependency: implementation "com.microsoft.onnxruntime:onnxruntime-extensions-android:0.9.0".
  6. Add onnxruntime-extensions-cios pod inside the example/ios/podfile, execute pod install in the terminal and add the onnxruntime_extension.xcframework provided by the installed pod following those stepsRunner > TARGETS > Runner > build Phases > Embed Frameworks.
  7. Go to the example folder > vad_iterator.dart > initModel method
  8. Add the registerCustomOps implementation if(Platform.isAndroid) { _sessionOptions!.registerCustomOpsLibrary('libortextensions.so'); } else if(Platform.isIOS){ _sessionOptions!.registerCustomOpsLibrary('onnxruntime_extensions.framework/onnxruntime_extensions'); }
  9. Run the application on both android and ios platforms

Link to fork with reproduction

Expected result

Onnxruntime extensions registred successfully.

Actual result

  1. Android works fine
  2. Ios shows the following error:
    
    [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: code=1, message=Failed to get symbol RegisterCustomOps with error: dlsym(0xbe91bda0, RegisterCustomOps): symbol not found
    #0      OrtStatus.checkOrtStatus (package:onnxruntime/src/ort_status.dart:29:5)
    #1      OrtSessionOptions.registerCustomOpsLibrary (package:onnxruntime/src/ort_session.dart:273:15)
    #2      VadIterator.initModel (package:onnxruntime_example/vad_iterator.dart:67:24)

I tried many solutions many of them are montioned in [https://github.com/dart-lang/native/issues/897](url) but no one works for this issue. Can any one give an explaination or have faced this issue.