I am trying to create an R package that has some functions in main.cpp which is dependent on an external Cpp library, libDAI. Let's say DAI1.cpp, DAI1.h, DAI2.cpp, DAI2.h and main.cpp are in the /src. I can install the package in this situation by including the libDAI source files in /src on Linux. (from main.cpp: #include "DAI1.h") However, this compiles all the libDAI components during the installation. I want to switch over to utilizing libDAI.a or libDAI.so which are already compiled in the package installation. Therefore, only main.cpp would be compiled and then linked with libDAI.a etc. during the package installation.
I have tried including it through Makevars, PKGLIBS but it didnt work as it tried to compile main.cpp first and then link libDAI.a which raised the error "could not find the header file" for #include <libDAI1.h>.
I've looked at the link below but still could not come up with a solution:
Rcpp: Install package with static libraries for platform independent usage
I thought this might also solve the problem of accessibility to the package throughout different platforms (Linux, Mac and Windows) but I guess there is not a static library solution for such a singularity etc. I've also browsed through some packages but still I am puzzled.
p.s. Currently, my Makevars only includes "PKGLIBS=-lgmp -lgmpxx". It suffices to load R, an old Boost version and have "gmp" R package (or libgmp-dev?) installed in the environment to be able to install my Rcpp package.
I have tried utilizing libDAI.a and libDAI.so through including in Makevars etc. but package works flawlessly only when I include source files in /src and they are compiled for each user during the installation.