I am writing a cli on Dart using a third-party library in the C language. I want to compile a single executable file. Is it possible? I linked the library dynamically using ffi. But is there a way to do statically, something like this ?
Asked
Active
Viewed 1,235 times
0
-
Does this answer your question? [How to statically link C code with Dart code to enable ffi with the dart ffi library](https://stackoverflow.com/questions/65047831/how-to-statically-link-c-code-with-dart-code-to-enable-ffi-with-the-dart-ffi-lib) – hacker1024 Nov 12 '21 at 04:47
-
Not really. I don't understand how I should link the library when compiling. Those. which instructions to use. If I use dynamic linking, I include the path to the library in the code `var myLib = DynamicLibrary.open(pathToMyLib)` But if I use it `var myLib = DynamicLibrary.executable()`, how do I statically link the library at compile time? – Aleksey Melikov Nov 12 '21 at 06:01
-
It's the same question though. This is a duplicate. – hacker1024 Nov 13 '21 at 11:14
-
Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Nov 13 '21 at 20:58
1 Answers
2
dart compile exe
does not currently support linking in static libraries (GitHub issue).
The best approach for now is to use DynamicLibrary.open
, open a dynamic library relative to the executable, and ship a zip/folder with an executable and dynamic libraries as the final app.

Daco Harkes
- 296
- 3
- 13