Dart是否支持与本机库的接口? [英] Does Dart support interfacing with the native libraries?

查看:134
本文介绍了Dart是否支持与本机库的接口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于服务器端部分变得更加复杂,开发人员将需要利用现有的软件。因此,Dart是否支持与本机库(特别是C库)的接口?

As the server-side part becomes more complex, developers will need to leverage the existing software. So, does Dart support interfacing with the native libraries (C libraries, in particular)?

推荐答案

这是官方指南。


在独立的Dart VM(命令行应用程序)上运行的Dart程序可以通过本机扩展调用共享库中的C或C ++函数。本文介绍如何在Windows,Mac OS X和Linux上编写和构建此类本机扩展。

Dart programs running on the standalone Dart VM (command-line apps) can call C or C++ functions in a shared library, by means of native extensions. This article shows how to write and build such native extensions on Windows, Mac OS X, and Linux.

您可以提供两种类型的本机扩展:异步或同步。异步扩展在单独的线程上运行本机函数,由Dart VM调度。同步扩展直接使用Dart虚拟机库的C API(Dart Embedding API),并在与Dart隔离器相同的线程上运行。通过向Dart端口发送消息,并在应答端口上接收响应来调用异步函数。

You can provide two types of native extensions: asynchronous or synchronous. An asynchronous extension runs a native function on a separate thread, scheduled by the Dart VM. A synchronous extension uses the Dart virtual machine library’s C API (the Dart Embedding API) directly and runs on the same thread as the Dart isolate. An asynchronous function is called by sending a message to a Dart port, receiving the response on a reply port.

这篇关于Dart是否支持与本机库的接口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆