Flutter: Dart FFI can't find symbol

532

It looks like the names in the dylib don't quite match the names in the C code. When I lookup the symbols by the names in the dylib, they resolve as expected.

The tool that I used to figure this out was the following:

nm -gU mylib.dylib
Share:
532
SuperDeclarative
Author by

SuperDeclarative

Updated on December 30, 2022

Comments

  • SuperDeclarative
    SuperDeclarative over 1 year

    I have included libavcodec.dylib in a Flutter project following the standard Flutter FFI instructions.

    Calling DynamicLibrary.open('libavcodec.59.dylib') executes without issue, and returns a non-negative handle address, which (I think) indicates a successful load.

    When I try to lookup any symbol, Flutter throws an error:

    "[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Invalid argument(s): Failed to lookup symbol...".

    When I call providesSymbol() with various symbol names, it always returns false.

    Does anyone know why this might be happening? Are there additional steps needed to bootstrap such a library? how I can debug the root cause of the issue?

    I think this is the root header file. This is the lib's documentation.