[Rcpp-devel] How to put the code 2013-01-05-r-function-from-c++.cpp in the src/ directory of a package?

Dirk Eddelbuettel edd at debian.org
Sat May 25 23:14:33 CEST 2013


On 25 May 2013 at 15:54, Dirk Eddelbuettel wrote:
| 
| On 25 May 2013 at 14:21, Peng Yu wrote:
| | > Try   sourceCpp("somefile.cpp",  verbose=TRUE)   to see how the examples
| | > using Rcpp Attributes add an additional layer that deal with .Call and SEXP
| | > arguments.
| | 
| | Hi Dirk,
| | 
| | When I try to replicate the method used sourceCpp, I get the following
| | error. I'm not sure what is wrong. Would you please take a look how to
| | fix the error? Thanks.
| | 
| | ~/dvcs_src/rexample/Rexample/cran/Rcpp/sourceCppFunction$ Rshl.sh main.cpp
| | llvm-g++-4.2 -arch x86_64 -dynamiclib -Wl,-headerpad_max_install_names
| | -undefined dynamic_lookup -single_module -multiply_defined suppress
| | -L/usr/local/lib -L/usr/local/lib -o main.so main.o
| | /Users/py/utility/R_user/Rcpp/lib/libRcpp.a
| | -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework
| | -Wl,CoreFoundation
| | ~/dvcs_src/rexample/Rexample/cran/Rcpp/sourceCppFunction$ Rscript main.R
| | > library(Rcpp)
| | > dl=dyn.load('main.so')
| | > callFunction=Rcpp:::sourceCppFunction(function(x, f) {}, FALSE, dl, 'callFunction')
| 
| You. Are. Still. Doing. It. Wrong.
| 
| Why did you think you'd need dyn.load?  Which of my posts to you had that?

PS  Rcpp:::sourceCppFunction() is also blatanly wrong.  I suggested
    sourceCpp(). And they are not the same thing.   

PPS Your error report was meant to be reproducible. You call some you named 
    'Rshl.sh' -- we do not know what it is in it. NOT reproducible. You call
    it on a file 'main.cpp'.  Which of course you do not show. 

Dirk

 
| Dirk
| 
| | > set.seed(42)
| | > x=rnorm(1e5)
| | > callFunction
| | function (x, f)
| | .Primitive(".Call")(<pointer: 0x103c73660>, x, f)
| | > callFunction(x, fivenum)
| | terminate called after throwing an instance of 'Rcpp::not_compatible'
| |   what():  cannot convert to function
| | Abort trap: 6
| | 
| | -- 
| | Regards,
| | Peng
| 
| -- 
| Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list