Such as boost, where can I specify the following:
1.External c++ header file include path
2.External c++ source file
3.External c++ link library file path
The 'Rcpp' package provides R functions as well as C++ classes which offer a seamless integration of R and C++. Many R data types and objects can be mapped back and forth to C++ equivalents which facilitates both writing of new code as well as easier integration of third-party libraries.
We can use the function sourceCpp to read a function written in C++ into R interactively. The function takes care of the compilation using R CMD SHLIB and automatically generates an R wrapper for the underlying function.
Packages are collections of R functions, data, and compiled code in a well-defined format, created to add specific functionality. There are 10,000+ user contributed packages and growing.
It all goes into src/Makevars
as explained in
the fine manual Writing R Extensions that came with R
either the Writing a package using Rcpp vignette or my book both of which I told you about in ...
... my replies to your post on rcpp-devel
Dirk's paper "Thirteen Simple Steps for Creating An R Package with an External C++ Library" gives an example src/Makevars
:
CXX_STD = CXX11
PKG_CFLAGS = -I. -DGMP -DSKIP_MAIN
PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) -lgmpxx -lgmp
As you can see, additional libraries are specified in PKG_LIBS
in this file. The src/Makevars
approach assumes that you incorporate C++ code into your project using a standard package layout, as produced by Rcpp.package.skeleton()
, with NAMESPACE
and DESCRIPTION
and so on.
According to Dirk's comments above, there is currently no way to specify an external library when C++ code is incorporated using the sourceCpp
function, because that function provides an interface which is supposed to be multi-platform.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With