How can I use a C++ shared library in a R package

c

#1

Hello all,
I have a C++ shared library that I’d like to use in a R package. I have tried to find a example on how to do that but couldn’t manage. Could someone help me with a reproducible example or a link where I could find a tutorial ?
Regards


#2

Does this help?

http://adv-r.had.co.nz/C-interface.html


#3

Hello sorry but I do not see anything mentioning shared library in there am I missing something ?


#4

Note sure - was thinking you could wrap your C++ functions this way? Admittedly, this is the extent of my current knowledge on the subject, so here is hoping that someone else can chime in to help.


#5

Are you referring to a library installed in the OS or do you want to include the library with the package? Which OS(s) do you target? Is the librrary header only or compiled?

Some select examples:

  • https://gist.github.com/jeroen/89073a6387e7169a40ec
  • RcppGSL links to a system installed GSL
  • nloptr links to a system installed nlopt or downloads and compiles the library
  • rzmq links to a system installed ZMQ
  • RcppArmadillo and RcppEigen ship header only libraries that are used by many other packages

#6

As I understand what you are trying to do, source C/++ inside an R-package, you must follow these standard steps R Packages: Compiled code

This will generate properly built packages which conform to a standardized structure which allows your R functions to act as thin wrappers for C/++ code.