0

What's the best way to compile and include a static library (in this case OpenCV) for use in a R package distributed as a binary package. Should I compile it as static outside of R and then put relevant .a files in "inst" or should I include all the source and header files of OpenCV in "inst" and compile from R?

I understand that CRAN will never accept this but it's more for the purpose of making deployment easier for users so they do not need to compile OpenCV or the package from source themselves.

If I get some good pointers on how to proceed or a package that have done something similar I intend to write up a short blog post for other people who want to do the same thing but with other large external libraries (both on Linux, OSX and Windows).

I apologies before hand if I've failed to appreciate that this question has been asked several times before.

  • 2
    There are a few packages which build _small_ static libraries in a subdirectory and then link to it. For something as large as OpenCV I am not sure that that is the best route. Come to rcpp-devel to discuss. – Dirk Eddelbuettel Oct 13 '16 at 12:20
  • And for dynamic library use see eg http://stackoverflow.com/questions/5307939/how-can-i-pass-flags-to-r-when-it-is-compiling-c-code-to-be-used-in-a-package – Dirk Eddelbuettel Oct 13 '16 at 14:09
  • Great I'll take the issue to rcpp-devel list. Already got everything working really nice using dynamic libraries. Image processing using R with OpenCV through Rcpp is about 4x-100x faster than other options for microscopic image processing such as Matlab, python or ImageJ/Fiji (java). So the gains are high. The issue is more for expanding the user base. Compiling OpenCV and such libraries from source will limit the number of users. Especially since even popular package management tools like homebrew or apt usually break for OpenCV when there is a major OS update. – Daniel Fürth Oct 13 '16 at 23:53
  • Right. I'd call getting libraries into the hands of inexperienced users _across platforms_ a real (and mostly unsolved) problem. One solution may be Docker. But first things first: let's build a rocking package. – Dirk Eddelbuettel Oct 14 '16 at 00:21

0 Answers0