A series of simple examples demonstrating how to call C libraries from Dart.
This code is designed to work with Dart version 2.12.0 and above.
To learn more about FFI, start with the C interop using dart:ffi guide on dart.dev.
Each sample uses CMake to generate a Makefile. To build the native library for each sample:
cd hello_world/hello_library
cmake .
make
The make
command creates a libhello.dylib
(macOS), libhello.dll
(Windows) or libhello.so
(Linux) library file.
Once the native library is built, run:
dart pub get
dart run <filename>.dart
The Dart binary can only load shared libraries that are signed. For more information, see dart-lang/sdk/issues/38314 for details.