Question

How to call Dart method from C++ code? I want to try use Dart as scripting language in my application.

Was it helpful?

Solution

You have two possibilities:

First, you can embed the Dart VM into your C++ program. See this discussion (there is a GitHub example). This allows you to write you program in C++ and run Dart scripts. I don't think that this way is supported by the Dart team directly, you need to do many things yourself.

Second, you can embed your C++ code into the Dart VM as a native extension. See this guide for details. This allows you to write your program in Dart and you can move performance critical parts or parts that need access to native libraries, to C++. There are many examples available.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top