I'm trying to understand how a platform might dynamically load a Roc app at runtime, i.e. a plugin use-case. I have limited knowledge and experience here so would appreciate any pointers to help me learn more about this. I am assuming this is how a plug-in might be built and used, though I wonder if a plug-in is just .roc
interface files instead?
I understand roc build
compiles a Roc app into a standalone static binary. One way to use this could be Rust's std::process::Command
and then IPC using something like interprocess::local_socket
to send data that has been serialised between the platform and plugin.
Or is there a better way? Maybe roc build --lib
to build a C library and then use the linker somehow?
The theoretical plan for dynamically using a roc app:
This can all be done at runtime and be dynamic.
We already do this for our tests
Each case is compiled to a shared library and loaded by the rust test runner.
Cool. Thanks for that, I didn't know you could do that. I'll have a closer look.
In rust we use: https://docs.rs/libloading/latest/libloading/
Last updated: Jul 05 2025 at 12:14 UTC