d0d0
d0d0

Reputation: 160

Including compiled shared C library in R package and calling functions in it from R wrapper functions

I have a compiled C-library (lib.dll) that I want to include in my R package so that several R functions I wrote for the package can access lib.dll's functions via .Call. I have no other C-source code in the package, and having lib.dll's source code build along with the package is not an option.

What would be the canonical way of including lib.dll in my package? Note that I'm not planning on submitting my package to CRAN, so CRAN's rules on compiled code are not that important to me, but I do want to eventually make the package available at some other online source, so always manually adding the dll after package installation would not be optimal. I feel like there is "normal" way of doing this but I can't seem to get it to work.

What I have tried sofar:

Upvotes: 1

Views: 432

Answers (1)

d0d0
d0d0

Reputation: 160

In case somebody has the same question, the answer was pretty simple and given explicity in the "Writing R Extensions" manual:

"The contents of the inst subdirectory will be copied recursively to the installation directory. Subdirectories of inst should not interfere with those used by R (currently, R, data, demo, exec, libs, man, help, html and Meta, and earlier versions used latex, R-ex)." So dlls and other files can simply be put into /inst and will end up in the installed package.

Upvotes: 1

Related Questions