Skip to content
Prev 4114 / 12125 Next

[R-pkg-devel] Link compiled C object to internal package file

Dear All,

Thanks for the input - it was sufficient for me to figure out a
solution, which I'll briefly describe here for future reference. This
draws primarily on the section of Writing R Extensions quoted by Martin
Morgan below, giving rise to the idea of combining environmental
variables, and the idea of I?aki Ucar (not posted to list) of defining
functional macros. Then it's quite simple:

1. Use system.file to set environmental variable on package load giving
full path to desired file.

2. Define macro as `#define MY_FILE_PATH getPath()`

3. Define the `getPath()` function as simply `char * getenv
("MY_FILE_PATH");`.

4. Insert `MY_FILE_PATH` macro for every desired reference to locally
packaged file.

Works perfectly! Thanks again,

mark
On 19/06/2019 17:46, Martin Morgan wrote: