[Rcpp-devel] Building/linking trouble with cxxfunction()

Douglas Bates bates at stat.wisc.edu
Wed Feb 16 19:18:12 CET 2011

On Wed, Feb 16, 2011 at 11:47 AM,  <Ken.Williams at thomsonreuters.com> wrote:
> Hi, I'm having some trouble wrapping a relatively simple C function using
> Rcpp and inline and friends.  This is my first time trying to use these
> tools, so I'm sure I'm doing something wrong  my immediate problem is
> that I can't seem to figure out how to link against a library when
> prototyping with cxxfunction().  My problem is explained here:
>  http://stackoverflow.com/questions/5009026/extract-long-from-r-object

The dgCMatrix object is of an S4 class.  It's best to use the S4 class
from Rcpp so you can extract the slots as Rcpp::IntegerVector and
Rcpp::NumericVector objects.  Once you get them in that form the
pointers are best obtained through the begin() method.  The lme4a
package in the lme4 project on R-forge uses these kinds of techniques
in the MatrixNs::chmSp class.  That class extends the cholmod_sparse
struct that is defined in the CHOLMOD sources.  You could similarly
extend the smat struct as a class (smat is actually simpler than
cholmod_sparse) and create a constructor like the chmSp constructor
that takes the S4 SEXP.

I can block out some code for you if you wish.

> Anyone have any advice?  I'm on OS X Snow Leopard.
> As an aside, have you considered moving this list to some open forum
> that's 1) searchable and 2) wouldn't require specific registration before
> posting?  StackOverflow would get my vote, since it focuses not just on
> answering questions but creating resources for those who come along
> afterwards.
> Thanks.
> [note, this is my second attempt sending this message, I think my first
> one was denied since I wasn't subscribed to the list (though I didn't get
> a notice to that effect).  Now I am.]
> --
> Ken Williams
> Senior Research Scientist
> Thomson Reuters
> Phone: 651-848-7712
> ken.williams at thomsonreuters.com
> http://labs.thomsonreuters.com
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

More information about the Rcpp-devel mailing list