Le 23 juin 2022 à 15:17, Serguei Sokol <serguei.sokol at gmail.com> a écrit :
Le 23/06/2022 à 15:02, THIOULOUSE JEAN a écrit :
Hi
Sorry to bother you again with my C/C++ problems in the ade4 package (available on CRAN & GitHub).
Thanks to your help, I have succeeded in converting several of the C functions to C++ using Rcpp. Now the package compiles without problem and all my C++ functions run fine in the dedicated GitHub branch of the package (ade4-Rcpp).
The new problem I am facing now is that in ade4, I use a library of about 30 utilities functions collected in one file named adesub.c, with adesub.h headers file. From what I understand, during package compilation these functions are added to the ade4 shared library and they can be called by my other C functions without being declared in the init.c or NAMESPACE files, as they do not need to be known by R.
I would like to know if it is possible to do the same thing in C++ with Rcpp.
If I understand correctly you goal, just don't put "// [[Rcpp::export]]" before your "internal" functions. They will be available to all C and C++ functions in src/ but not seen in R. You don't need extra "R CMD SHLIB" either.
Best,
Serguei.
I have found reading the documentation (Dirk's book and Rcpp vignettes) that I could use R CMD SHLIB to build a shared library and then dyn.load it in R. I have created a file named ade4lib.cpp containing the utilities functions in the src directory, and I can make the shared library (ade4lib.so) with RCMD SHLIB. But this does not solve my problem because, as I understand it, this makes the utilities library functions available to R (which is useless since they are not interfaced correctly to R but to C++), and not to the other C++ functions (which is what i need to do).