简体   繁体   English

如何将 C 代码与 Dart 代码静态链接以启用 ffi 与 dart ffi 库

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

I'm trying to write a dart binary application and link in C code with it.我正在尝试编写一个 dart 二进制应用程序并用它链接 C 代码。

I read the documentation and I understand how to do the actually ffi at runtime我阅读了文档,并且了解如何在运行时执行实际的 ffi

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.但我不明白如何将我的 C 代码静态链接到构建过程中,因为我不想分发二进制文件以及单独的共享库。

Any advice would be helpful and thanks in advance任何建议都会有所帮助,并在此先感谢

Hi give a look at this maybe it will help you solve this problem [dart:ffi][1]嗨,看看这个也许它会帮助你解决这个问题 [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(). [1]: https://flutter.dev/docs/development/platform-integration/c-interop ,你也在使用正确的 DinamicLibrary,我认为它不会有帮助,但你为什么不试一试,chane可执行并添加进程()。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM