On 7 November 2018 at 14:49, Barth Riley wrote:
| I apologize if this question has been asked before but after doing several 
searches I could not find an answer that is directly applicable to my problem. 
I am working on a package containing a number of Rcpp functions. The package 
builds and loads without a problem. However, when I call any of the Rcpp 
functions from within R, I get the following type of error message:
| 
| Error in .Call(<pointer: (nil)>, x, xMin, xMax, adjustment) : 
|   NULL value passed as symbol address

Something went wrong here.

And we can't tell from the incomplete example you posted.

I suggest you start fresh with a new baby package (maybe via
Rcpp.package.skeleton, maybe via the RStudio helper), see that that works (it
should, does for everybody else and testing) and then add to it, slowly and
carefully.  With some care the difference should eventually reveal itself.

| As an example, here is the function that returned the error in the C++ file:
| 
| // [[Rcpp::export]]
| NumericVector logit(Rcpp::NumericVector x, 
|                     Rcpp::NumericVector xMin,
|                     Rcpp::NumericVector xMax, 
|                     double adjustment = 0.3) {
| 
|   ...
| 
| }
| 
| The exported function in RcppExports.cpp:
| 
| // logit
| NumericVector logit(Rcpp::NumericVector x, Rcpp::NumericVector xMin, 
Rcpp::NumericVector xMax, double adjustment);
| RcppExport SEXP _MFRM_logit(SEXP xSEXP, SEXP xMinSEXP, SEXP xMaxSEXP, SEXP 
adjustmentSEXP) {
| BEGIN_RCPP
|     Rcpp::RObject rcpp_result_gen;
|     Rcpp::RNGScope rcpp_rngScope_gen;
|     Rcpp::traits::input_parameter< Rcpp::NumericVector >::type x(xSEXP);
|     Rcpp::traits::input_parameter< Rcpp::NumericVector >::type xMin(xMinSEXP);
|     Rcpp::traits::input_parameter< Rcpp::NumericVector >::type xMax(xMaxSEXP);
|     Rcpp::traits::input_parameter< double >::type adjustment(adjustmentSEXP);
|     rcpp_result_gen = Rcpp::wrap(logit(x, xMin, xMax, adjustment));
|     return rcpp_result_gen;
| END_RCPP
| }
| 
| And the corresponding R file:
| 
| logit <- function(x, xMin, xMax, adjustment = 0.3) {
|     .Call(`_MFRM_logit`, x, xMin, xMax, adjustment)
| }
| 
| First, how can there be two functions called "logit"--one in the main C++ 
file and one in RcppExports.cpp? And where does _MFRM_logit get defined? Might 
this be causing the problem?

Not a problem per se.  The one here is a just a declaration -- standard C and
C++ practice.
| 
| I should note that hte problem is not limited to this one function, but to 
all the exported C++ functions. 
| 
| Second, is there some option in the project or in the C++ files that needs to 
be set? 

I don't understand your question -- but we try to document all necessary
steps.

Dirk

| I am running R 3.51, RStudio 1.14, and Rcpp (0.12.19).
| _______________________________________________
| 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

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org
_______________________________________________
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

Reply via email to