Help vendoring in a 3rd party library



My goal is to create a binding to librdkafka for use in R and distribute it on CRAN. My working pull request is here. I've tried lots of things, and attempted to follow other's examples such as:

  • How can I use a C++ shared library in a R package
  • stackoverflow post 31754107
  • And a variety of github autconf (for example the cairo package) and other methods such as autobrew (like RPostgresql) or install.libs.R (like LightGBM)
  • Just including headers and relying on system level deps for linking (like a lot of Rcpp wrappers). But that's not CRAN viable

but i've followed the provided examples (or do not understand them) and am still having trouble getting my package to pass R CMD check. Essentially what's occurring is the package can compile correctly, but it's not portable so it fails R CMD INSTALL because the linked library doesn't move with the package.

Currently I am trying to move the compiled librdkafka++.a/so libraries to inst/libs so that they are moved in the installation and then trying to make link against it correctly. Unfortunately I'm having no luck.

Can anyone point me to the correct fashion to download/make/and link against a third party library such that an R package is CRAN viable?


(side note i'm limited to 2 links so i wasn't able to post urls in the body)