Here is a MWE of the workflow I was describing for passing a user-d https://gist.github.com/kylebmetrum/6b31775702e1b8441a1cff669aeb0f1d
I used sourceCpp() to mimic the code in an R package and used R CMD SHLIB to compile the user function. It would be great to be able to use sourceCpp() to compile the user function too, but I wasn't sure how to determine the name of the dll (to pass as PACKAGE to getNativeSymbolInfo()). Anyway ... maybe there is a simpler way to do it. But this is basically what I do in mrgsolve. Best Regards, Kyle On Thu, Apr 14, 2016 at 5:03 PM, Dirk Eddelbuettel <e...@debian.org> wrote: > > On 14 April 2016 at 17:28, Martin Lysy wrote: > | I am very grateful for your input/recommendations. Let me try to wrap > my head > | around how to do this with a single package and get your approval on an > MWE. > > That's the spirit, and we'll try to help. > > I won't claim that this is _trivial_ but it is _very expressive_ and > powerful. A worked example is in RcppDE: user-provided objective function > as C++ code, passed down to the bowels of the optimizer. The interface > takes > a little getting used but I think we have both a Rcpp Gallery piece on it, > and I used it as a running example in a few talks to Google may lead us to > the right slide deck. > > That said, no point in overcomplicating things but ... your initial problem > was a self-inflicted linking issue just because you wanted to avoid a > package. > > Don't. > > Let users work with with sourceCpp() or cppFunction(). What comes out is a > callable R object to just pass into your code. That's all you need. > > Good luck, Dirk > > PS And whatever you do don't listen to your colleage Markus Hofter who has > really weird coding habits too. Just kidding. Tell him I said Hi. > > -- > http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org > -- Kyle Baron Metrum Research Group 860-735-7043, Ext. 202 ky...@metrumrg.com
_______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel