Each of these cppFunction
calls create an independent shared library. They don't know about each other.
An easy alternative is to have all on the same file:
#include <Rcpp.h>
// [[Rcpp::export]]
double normal_dens( double x ) {
const double SQRT2PI = 2.50662827463;
return( exp(-x*x/2.0)/SQRT2PI );
}
// [[Rcpp::export]]
double test( double x ,double a){
return( a* normal_dens(x););
}
and then call sourceCpp
on this file. Then later, you'll want to learn how to make packages.