[Rcpp-devel] No matching function for calls to Rmath.h

Davor Cubranic cubranic at stat.ubc.ca
Thu Sep 16 00:27:25 CEST 2010


For some reason, after upgrading Rcpp from 0.8.3 to 0.8.6 and RcppArmadillo from 0.2.3 to 0.2.6, my code cannot use functions in Rmath.h. This happens in R 2.10.1 and 2.11.1. Example:

fx <- cxxfunction( signature( a = "numeric", b = "numeric" ), '
Rcpp::NumericVector xa(a);
Rcpp::NumericVector xb(b);
int n = xa.size() ;
Rcpp::NumericVector xdpois(n);
for (int i = 0; i < n; i++) {
  xdpois = dpois(xa(i), xb(i), 0);
}
return xdpois;

', includes="#include <Rmath.h>", plugin = "Rcpp" )

file44c9b62d.cpp: In function 'SEXPREC* file44c9b62d(SEXPREC*, SEXPREC*)':
file44c9b62d.cpp:35: error: no matching function for call to 'dpois(double&, double&, int)'
make: *** [file44c9b62d.o] Error 1

ERROR(s) during compilation: source code errors or compiler configuration errors!

Program source:
  1: // includes from the plugin
  2: 
  3: #include <Rcpp.h>
  4: 
  5: 
  6: #ifndef BEGIN_RCPP
  7: #define BEGIN_RCPP
  8: #endif
  9: 
 10: #ifndef END_RCPP
 11: #define END_RCPP
 12: #endif
 13: 
 14: using namespace Rcpp;
 15: 
 16: 
 17: // user includes
 18: #include <Rmath.h>
 19: 
 20: // declaration
 21: extern "C" {
 22: SEXP file44c9b62d( SEXP a, SEXP b) ;
 23: }
 24: 
 25: // definition
 26: 
 27: SEXP file44c9b62d( SEXP a, SEXP b ){
 28: BEGIN_RCPP
 29: 
 30: Rcpp::NumericVector xa(a);
 31: Rcpp::NumericVector xb(b);
 32: int n = xa.size() ;
 33: Rcpp::NumericVector xdpois(n);
 34: for (int i = 0; i < n; i++) {
 35:   xdpois = dpois(xa(i), xb(i), 0);
 36: }
 37: return xdpois;
 38: 
 39: 
 40: END_RCPP
 41: }
 42: 
 43: 
Error in compileCode(f, code, language = language, verbose = verbose) : 
  Compilation ERROR, function(s)/method(s) not created!


More information about the Rcpp-devel mailing list