dylib 0.3.3 copy "dylib: ^0.3.3" to clipboard
dylib: ^0.3.3 copied to clipboard

A set of helpers for resolving names and paths of dynamic libraries.

example/example.dart

import 'dart:ffi' as ffi;

import 'package:dylib/dylib.dart';

void main() {
  libfoo.bar();
}

LibFoo? _libfoo;
LibFoo get libfoo {
  return _libfoo ??= LibFoo(ffi.DynamicLibrary.open(
    resolveDylibPath(
      'foo', // foo.dll, libfoo.so, libfoo.dylib...
      dartDefine: 'LIBFOO_PATH',
      environmentVariable: 'LIBFOO_PATH',
    ),
  ));
}

// e.g. generated by ffigen
class LibFoo {
  final ffi.DynamicLibrary _dylib;
  LibFoo(this._dylib);

  int bar() {
    return (_fooBar ??=
        _dylib.lookupFunction<_CFooBar, _DartFooBar>('foo_bar'))();
  }

  _DartFooBar? _fooBar;
}

typedef _CFooBar = ffi.Int32 Function();
typedef _DartFooBar = int Function();
16
likes
160
pub points
72%
popularity

Publisher

unverified uploader

A set of helpers for resolving names and paths of dynamic libraries.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

meta, path, platform

More

Packages that depend on dylib