[Rcpp-devel] inline plug-in linking

Ian Fellows ian.fellows at stat.ucla.edu
Fri Nov 16 17:33:47 CET 2012

Hi All,

I'm attempting to get inline up and running for my package, but am having some trouble. My plug in statement is:

inlineErnmPlugin <- Rcpp:::Rcpp.plugin.maker(
		include.before = "#include <ernm.h>", 
		libs           = "", 
		package        = "ernm"

This works for some things. for example:

src <- "
		Rcpp::IntegerMatrix tmp(0,2);
		ernm::BinaryNet<ernm::Directed> net(tmp,Rcpp::as<int>(n));
		return net;
emptyNetwork <- cxxfunction(signature(n="integer"), src, plugin="ernm")
net <- emptyNetwork(10)

but for others it doesn't work. In particular, I keep a list of available "model statistics" in a static class StatController, which I want my user to be able to add to. When I try to interact with this list (well, map technically), I get linking errors. I found a work around where the user could bring an XPtr to the stat up to R, and then pass it down to add to the list with an exposed Module function. This worked fine until the user quit R, at which point a memory not mapped seg fault occurred.

Anyhow, I think I am probably missing some linking info from my inlinePlugIn statement. I tried to hard code the library (perhaps naively), but got image not found errors.
ip <- Rcpp:::Rcpp.plugin.maker(
		include.before = "#include <ernm.h>", 
		libs           = "/Library/Frameworks/R.framework/Resources/library/ernm/libs/i386/ernm.so", 
		package        = "ernm"

A reproducible example is located at http://fellstat.com/files/ernmInlineTests.R for use with http://fellstat.com/files/ernm_1.0.tar.gz . The only code in the package that the examples interact with is StatController.h and StatController.cpp.

Any guidance would be greatly appreciated.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20121116/5cc7163a/attachment-0001.html>

More information about the Rcpp-devel mailing list