Discussion:
[Rcpp-devel] Rcpp package structure
Vissarion Fisikopoulos
2018-07-12 13:32:08 UTC
Permalink
Hi all,

I am mentoring a gsoc project on development of a C++ library with an
R interface using Rcpp.

Currently the project has the following structure: let root be the
main folder of the package, the default Rcpp package structure is in
root/R-proj, C++ header files are in root/include and we have some
tests for the C++ functions in root/test as well as external libraries
in root/external.

The package can be installed successfully without any problems (since
in makevars we include all the files from root/include) but if we run
devtools::check() in root/R-proj, it returns an error because it seems
that it is not able to see files outside R package main folder which
is root/R-proj.

It seems that devtools expect to have C++ sources inside root/R-proj
but then either we mix the C++ sources with the R interface or we keep
two copies of the C++ sources (one inside R-proj and one outside).
Since both solutions seem problematic to me I would like to ask what
is the recommended structure for such a project?

Thanks and best regards,
Vissarion.
Iñaki Úcar
2018-07-12 13:56:36 UTC
Permalink
El jue., 12 jul. 2018 a las 15:32, Vissarion Fisikopoulos
Post by Vissarion Fisikopoulos
Hi all,
I am mentoring a gsoc project on development of a C++ library with an
R interface using Rcpp.
Currently the project has the following structure: let root be the
main folder of the package, the default Rcpp package structure is in
root/R-proj, C++ header files are in root/include and we have some
tests for the C++ functions in root/test as well as external libraries
in root/external.
The package can be installed successfully without any problems (since
in makevars we include all the files from root/include) but if we run
devtools::check() in root/R-proj, it returns an error because it seems
that it is not able to see files outside R package main folder which
is root/R-proj.
It seems that devtools expect to have C++ sources inside root/R-proj
but then either we mix the C++ sources with the R interface or we keep
two copies of the C++ sources (one inside R-proj and one outside).
Since both solutions seem problematic to me I would like to ask what
is the recommended structure for such a project?
See this thread:
https://stat.ethz.ch/pipermail/r-package-devel/2017q2/001680.html

Summing up, a shared library must be installed in a standard location,
otherwise, it should be under R-proj/src. For example, this is what
MonetDBLite does:
https://github.com/hannesmuehleisen/MonetDBLite-R/tree/master/src

If you are using git, I think that a good approach is to have a repo
for the main C++ library and to add it as a git submodule under src/
in the R package repo. This eases the burden of code synchronisation.
But then you need to remember to always clone recursively.

Hope it helps.
Iñaki
Post by Vissarion Fisikopoulos
Thanks and best regards,
Vissarion.
_______________________________________________
Rcpp-devel mailing list
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Dirk Eddelbuettel
2018-07-12 22:26:22 UTC
Permalink
On 12 July 2018 at 15:56, Iñaki Úcar wrote:
| El jue., 12 jul. 2018 a las 15:32, Vissarion Fisikopoulos
| (<***@gmail.com>) escribió:
| >
| > Hi all,
| >
| > I am mentoring a gsoc project on development of a C++ library with an
| > R interface using Rcpp.
| >
| > Currently the project has the following structure: let root be the
| > main folder of the package, the default Rcpp package structure is in
| > root/R-proj, C++ header files are in root/include and we have some
| > tests for the C++ functions in root/test as well as external libraries
| > in root/external.
| >
| > The package can be installed successfully without any problems (since
| > in makevars we include all the files from root/include) but if we run
| > devtools::check() in root/R-proj, it returns an error because it seems
| > that it is not able to see files outside R package main folder which
| > is root/R-proj.
| >
| > It seems that devtools expect to have C++ sources inside root/R-proj
| > but then either we mix the C++ sources with the R interface or we keep
| > two copies of the C++ sources (one inside R-proj and one outside).
| > Since both solutions seem problematic to me I would like to ask what
| > is the recommended structure for such a project?
|
| See this thread:
| https://stat.ethz.ch/pipermail/r-package-devel/2017q2/001680.html
|
| Summing up, a shared library must be installed in a standard location,
| otherwise, it should be under R-proj/src. For example, this is what
| MonetDBLite does:
| https://github.com/hannesmuehleisen/MonetDBLite-R/tree/master/src
|
| If you are using git, I think that a good approach is to have a repo
| for the main C++ library and to add it as a git submodule under src/
| in the R package repo. This eases the burden of code synchronisation.
| But then you need to remember to always clone recursively.

Or have it in the same repo but maybe copy/link at build time.

The package layout requirement is an R issue, and is not imposed by Rcpp.

Dirk
--
http://dirk.eddelbuettel.com | @eddelbuettel | ***@debian.org
Loading...