[Rcpp-devel] Linking R package to a static library(For testing) resulting compilation failure

Dirk Eddelbuettel edd at debian.org
Sat Mar 21 20:15:50 CET 2020


On 21 March 2020 at 11:31, Akhila Chowdary Kolla wrote:
|  *How can I compile Rcpp package or src/*.cpp files to get an executable

In general,you can't.

Rcpp is for R extensions, i.e. dynamically loadable modules you load from R.

Now, you could --- and many of us do --- encode functionality in a package to
be loaded by R and then use an R script to load that package and run. There
are many tools for that.

But it looks like you have a 'compiled code test harness as executables'
mindset which is not applicable here.

| and linking a static library to it while it is being compiled.*

By adding it as an argument to PKG_LIBS in the package.

|  *How can I generate an executable Rcpp package using the command

"Executable Rcpp package" ? That makes no sense.

As stated, you can't build "an executable".  (We have a siblling project
RInside permitting you to embed the R interpreter easily in an
executable. Maybe that can help.)

How to build _an R package_ with Rcpp is documented in many tutorials. I
would suggest you (maybe re-)the introductory vignette to Rcpp and then look
at the Rcpp Attributes vignette.

| line(command) by linking deep state library instead of generating a
| RcppDeepState.so(not an executable) file dynamically using (R CMD INSTALL
| .)*

Creating a working package is as simple as calling
   Rcpp.package.skeleton("myPKG")

The key then is how to add to it. I can't explain that in two lines here --
there is a reason we have nine vignettes in the package.

Hth, Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the Rcpp-devel mailing list