[Rcpp-devel] Shared code in C++ files
Dirk Eddelbuettel
edd at debian.org
Fri Apr 15 00:03:13 CEST 2016
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 | edd at debian.org
More information about the Rcpp-devel
mailing list