On Wednesday, 2 June 2021 at 23:23:58 UTC, bachmeier wrote:
Are you aware of my embedr project, which handles all that for
you, and does a lot of other stuff?
https://embedr.netlify.app
If you want to do it yourself, you can see the boilerplate you
need to add to call a shared library from R here:
https://bitbucket.org/bachmeil/embedr/src/bebf67e5b30cd4163214c7f44f9907e7d7490dc0/R/compile.R#lines-99
If you want to read the R manual, the relevant section is here:
https://cran.r-project.org/doc/manuals/r-release/R-exts.html#dyn_002eload-and-dyn_002eunload
If you don't do that, it's unlikely to work unless you get
lucky. If you want to load foo.so, you need a corresponding
R_init_foo function where you call Runtime.initialize.
Thanks. Looks like I have some more reading to do. I did know
about embedr, but I saw it had dependencies and I wanted a
standalone and fully transparent D solution. I'm already calling
R routines from D using standalone Rmath and being able to call D
from R and D have independent full access to R's internals would
be awesome. But your package certainly provides very useful
information.
The reference to R's dyn.load internals looks useful and relevant
and I'll be trying those once I get the time. Probably during the
weekend.