<div dir="ltr"><div><div><div>Why must I call my C++ function using the `.Call()` syntax? Why can't I call it by name? Other C++ functions in my package do not have this problem. It's just this one that has the NULL symbol address.<br></div></div><div><br>```<br>> library(kamlib)<br><br>Attaching package: ‘kamlib’<br><br>> expected_errors(c('####'))<br>Error in .Primitive(".Call")(<pointer: 0x0>, xs) : <br>  NULL value passed as symbol address<br><br>> .Call('kamlib_expected_errors', PACKAGE = 'kamlib', c('####'))<br>[1] 2.52384<br>```<br><br></div>I created a package called 'kamlib'. In that package, I have a C++ file called 'expected_errors.cpp' with this code:<br><br>```<br>#include <Rcpp.h><br>#include <string.h><br>using namespace Rcpp;<br><br>// [[Rcpp::export]]<br>NumericVector expected_errors(CharacterVector xs) {<br>  const double probs[] = {<br>    0.79433, 0.63096, 0.50119, 0.39811, 0.31623, 0.25119, 0.19953,<br>    0.15849, 0.12589, 0.10000, 0.07943, 0.06310, 0.05012, 0.03981,<br>    0.03162, 0.02512, 0.01995, 0.01585, 0.01259, 0.01000, 0.00794,<br>    0.00631, 0.00501, 0.00398, 0.00316, 0.00251, 0.00200, 0.00158,<br>    0.00126, 0.00100, 0.00079, 0.00063, 0.00050, 0.00040, 0.00032,<br>    0.00025, 0.00020, 0.00016, 0.00013, 0.00010, 0.00008<br>  };<br>  NumericVector res(xs.size());<br>  for (int i = 0; i < xs.size(); i++) {<br>    for (int j = 0; j < strlen(xs[i]); j++) {<br>      res[i] += probs[ (int) xs[i][j] - 34 ];<br>    }<br>  }<br>  return res;<br>}<br>```<br><br></div>My `RcppExports.R` file looks perfectly fine:<br><br>```<br># This file was generated by Rcpp::compileAttributes<br># Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393<br><br>expected_errors <- function(xs) {<br>    .Call('kamlib_expected_errors', PACKAGE = 'kamlib', xs)<br>}<br><br>sos <- function(xs) {<br>    .Call('kamlib_sos', PACKAGE = 'kamlib', xs)<br>}<br>```<br></div>