Hello, I tried to call an external function of R from the following code in C++:
void prodgdot(double *x, double *y, int *n, double *output) { int i; *output=0; for (i=0;i<*n;i++) { *output+=x[i]*y[i]; } } I compiled it using from my working directory in linux terminal and I think it's ok: [EMAIL PROTECTED]:~/mysrc/meus_testes_iniciais$ R CMD SHLIB codigoprova.cc # The output g++ -I/usr/share/R/include -I/usr/share/R/include -fpic -g -O2 -c codigoprova.cc -o codigoprova.o g++ -shared -o codigoprova.so codigoprova.o -L/usr/lib/R/lib -lR After, I tried to call R from my working directory an Error occurs: > x<-c(1,4,6,2) > y<-c(3,2.4,1,9) > dyn.load("codigoprova.so") > is.loaded("codigoprova.so") [1] FALSE > product<-.C("prodgdot",myx=x,muy=y,myn=NROW(x),myoutput=as.double(0)) Error in .C("prodgdot", myx = x, muy = y, myn = NROW(x), myoutput = as.double(0)) : C symbol name "prodgdot" not in load table > Does anyone know what is the problem? Thank's in advance! Gilberto.
______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.