How to statically link C code with Dart code to enable ffi with the dart ffi library

961 views Asked by At

I'm trying to write a dart binary application and link in C code with it.

I read the documentation and I understand how to do the actually ffi at runtime

final lib = ffi.DynamicLibrary.executable();
final VoidFunc greet = lib.lookup<ffi.NativeFunction<CVoidFunc>>('greet').asFunction();

but I don't understand how to statically link my C Code into the build process because I don't want to have to distribute a binary as well as a separate shared library.

Any advice would be helpful and thanks in advance

1

There are 1 answers

1
gregni On

Hi give a look at this maybe it will help you solve this problem [dart:ffi][1]

[1]: https://flutter.dev/docs/development/platform-integration/c-interop ,also you are using right the DinamicLibrary , i dont think that it will be helpful but why not you give it a try , chane executable and add process().