Question

I want to use a c function "rpg_hybrid" that correspond to R library BayesLogit rpg (http://www.inside-r.org/packages/cran/BayesLogit/docs/rpg) in my Rcpp code. I have include LogitWrapper.h and also the library BayesLogit.so to linking stage. GCC still cannot find the rpg_hybrid.

Was it helpful?

Solution

Although it seems like you've solved your problem, I'll provide an answer in the context of developing an R package that you might want to e.g. release to CRAN.


Basically, the authors of BayesLogit need to explicitly make such routines available for other package authors. This is described in section 5.4.2 of R-exts. From what I can see from the source code, this has not been done, so you will be unable to call the native C/C++ code in that package in a portable, and hence CRAN-acceptable, way.

Your options are:

  1. Contact the package authors and ask if they can make this routine available,
  2. Copy the source to your own package and give attribution; if you do this, make sure the licence you use is compatible with theirs.

As an aside, Rcpp also has facilities for making source code available in a header only way. The package authors might be convinced to make some routines available by using Rcpp Attributes, as it provides a simple mechanism for allowing other authors to use C++ code in a package; see section 3.5.

OTHER TIPS

A student in my class pointed me to your query. Although I haven't had time to do the things Kevin/Dirk suggested, I have posted a more user-friendly C++ API to my Github page. See https://github.com/jgscott/helloPG

This comes in the form of a R package skeleton which can easily be modified. I hope this will be a workable standby in the interim, until we can modify BayesLogit appropriately.

-James

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top