Integrating un4seen BASS with Flutter using FFI and getting symbol error

Viewed 30

I'm trying to integrate the BASS audio library from un4seen Developments with Flutter, Google's cross-platform app development environment. I've started a Flutter plugin that can be found here: https://github.com/JimTompkins/flutter_bass. It uses Flutter's FFI (foreign function interface) mechanism and a package called ffigen to convert the bass.h file to generated_bindings.dart.

Here is a snippet from generated_bindings.dart:

  int BASS_Init(
    int device,
    int freq,
    int flags,
    ffi.Pointer<ffi.Void> win,
    ffi.Pointer<ffi.Void> dsguid,
  ) {
    return _BASS_Init(
      device,
      freq,
      flags,
      win,
      dsguid,
    );
  }

  late final _BASS_InitPtr = _lookup<
      ffi.NativeFunction<
          BOOL Function(ffi.Int32, DWORD, DWORD, ffi.Pointer<ffi.Void>,
              ffi.Pointer<ffi.Void>)>>('_BASS_Init');
  late final _BASS_Init = _BASS_InitPtr.asFunction<
      int Function(
          int, int, int, ffi.Pointer<ffi.Void>, ffi.Pointer<ffi.Void>)>();

It builds (Flutter 3.3, XCode 13) but throws a run-time error when I try to call the BASS_init function: Failed to lookup symbol '_BASS_Init': dlsym(0x100f61e18, _BASS_Init): symbol not found

I can see the symbol in the libbass.a file using nm -gU libbass.a

Any comments/suggestions welcomed!

Update 2022-09-20: I added the following frameworks to the Xcode build: AVFoundation, AudioToolbox, SystemConfiguration, CFNetwork, Accelerate In Xcode by going to Build Phase-->Link Binary with Libraries-->Add This did not make any difference i.e. still getting symbol error

I checked that “Enable bitcode” is set to “No” in Xcode under Build Settings-->Build Options.

The search continues...

0 Answers
Related