Hi I am trying to build an R package using a pre-compiled static library and a single header file. What is the best way to do so?
Because I didn’t find any information on it (only on creating R packages that compile from src), I settled on writing a thin C++ wrapper class in the extension src directory. I also added the one header file I need for the library to the src directory, and could now theoretically link to the library on my computer (I reckon). However, I’d like to ship that static library with my package, which should also make linking easier (I could just hardcode it to the package directory).
Any ideas?
Thanks
First off, any extension package to R containing compiled source code will be dyanmically linked — as R loads it at run-time.
That said, any external dependencies of your code could be statically linked into the extension package. For that to happen, you could try to just list the static library with its full path in the
PKG_LIBSargument — and standard way to enforce static linking.Off-hand I cannot think of a CRAN package example using this approach or I’d would suggest it as a stanza.