Skip to content

parths-test-org/demo-dart

 
 

Repository files navigation

Dart FFI Samples

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.

Building native libraries

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.

Running

Once the native library is built, run:

dart pub get
dart run <filename>.dart

macOS code signing

The Dart binary can only load shared libraries that are signed. For more information, see dart-lang/sdk/issues/38314 for details.

Releases

No releases published

Packages

No packages published

Languages

  • Dart 76.0%
  • C 18.2%
  • CMake 5.6%
  • Shell 0.2%