Since a longer time now it is possible to open a DynamicLibrary (dylib, dll, so) in Flutter. Those libraries are written in C or C++.
I've now tried to build a basic dart command line application, compiled it using dart compile exe
and tried to load it in my Flutter application using DynamicLibrary.open()
, as you would do with the native libraries in C/C++.
typedef HelloWorldFunc = Void Function();
typedef HelloWorld = void Function();
...
final dynLib = DynamicLibrary.open('/path/to/cli.exe');
final HelloWorld func = dynLib.lookup<NativeFunction<HelloWorldFunc>>('hello_world').asFunction();
func();
(I've followed this tutorial and just added an empty void function called hello_world https://dart.dev/tutorials/server/get-started#3-create-a-small-app)
But the symbol could not be found:
Failed to lookup symbol 'hello_world': dlsym(0x7fec2310e5a0, hello_world): symbol not found
Question
Is it generally possible to open dart-compiled libraries in Flutter, like DLLs written in C++? Since dart compile exe
generates native machine code as well
If yes, how?
Thanks!