Hello: This is a simple, I hope, question about the first example in section 3.6.4 of the manual, "Writing R extensions." I'm using R 1.1.0, and below I list some easy code that I got from section 3.6.4. When I try to compile the file out.c under NT 4, using VC++ 6.0, I get the following error messages: Compiling... out.c Linking... out.obj : error LNK2001: unresolved external symbol _Rf_unprotect out.obj : error LNK2001: unresolved external symbol _Rf_protect out.obj : error LNK2001: unresolved external symbol _Rf_allocMatrix out.obj : error LNK2001: unresolved external symbol _Rf_length I see, for example, that PROTECT(s) is #defined as protect(s) in R.h, #ifndef R_NO_REMAP. If I do nothing, I get the errors above, and if I #idefine R_NO_REMAP, I get the following errors, instead: Compiling... out.c Linking... out.obj : error LNK2001: unresolved external symbol _unprotect out.obj : error LNK2001: unresolved external symbol _protect out.obj : error LNK2001: unresolved external symbol _allocMatrix out.obj : error LNK2001: unresolved external symbol _length I cannot seem to find these 4 functions anywhere. Hopefully, I am just missing them. Can anyone help? Here is the file out.c: #include <R.h> #include <Rinternals.h> SEXP out(SEXP x, SEXP y) { int i, j, nx, ny; double tmp; SEXP ans; nx = length(x); ny = length(y); PROTECT(ans = allocMatrix(REALSXP, nx, ny)); for(i = 0; i < nx; i++) { tmp = REAL(x)[i]; for(j = 0; j < ny; j++) REAL(ans)[i + nx*j] = tmp * REAL(y)[j]; } UNPROTECT(1); return(ans); } -------------- next part -------------- An HTML attachment was scrubbed... URL: https://stat.ethz.ch/pipermail/r-help/attachments/20000626/1d78cb97/attachment.html
Sorry to bother you: the functions are in memory.c, in the main src subdirectory. -----Original Message----- From: Richards, Tom Sent: Monday, June 26, 2000 6:38 PM To: r-help at stat.math.ethz.ch Subject: [R] Looking for protect() Hello: This is a simple, I hope, question about the first example in section 3.6.4 of the manual, "Writing R extensions." I'm using R 1.1.0, and below I list some easy code that I got from section 3.6.4. When I try to compile the file out.c under NT 4, using VC++ 6.0, I get the following error messages: Compiling... out.c Linking... out.obj : error LNK2001: unresolved external symbol _Rf_unprotect out.obj : error LNK2001: unresolved external symbol _Rf_protect out.obj : error LNK2001: unresolved external symbol _Rf_allocMatrix out.obj : error LNK2001: unresolved external symbol _Rf_length I see, for example, that PROTECT(s) is #defined as protect(s) in R.h, #ifndef R_NO_REMAP. If I do nothing, I get the errors above, and if I #idefine R_NO_REMAP, I get the following errors, instead: Compiling... out.c Linking... out.obj : error LNK2001: unresolved external symbol _unprotect out.obj : error LNK2001: unresolved external symbol _protect out.obj : error LNK2001: unresolved external symbol _allocMatrix out.obj : error LNK2001: unresolved external symbol _length I cannot seem to find these 4 functions anywhere. Hopefully, I am just missing them. Can anyone help? Here is the file out.c: #include <R.h> #include <Rinternals.h> SEXP out(SEXP x, SEXP y) { int i, j, nx, ny; double tmp; SEXP ans; nx = length(x); ny = length(y); PROTECT(ans = allocMatrix(REALSXP, nx, ny)); for(i = 0; i < nx; i++) { tmp = REAL(x)[i]; for(j = 0; j < ny; j++) REAL(ans)[i + nx*j] = tmp * REAL(y)[j]; } UNPROTECT(1); return(ans); } -------------- next part -------------- An HTML attachment was scrubbed... URL: https://stat.ethz.ch/pipermail/r-help/attachments/20000626/763600ab/attachment.html
On Mon, Jun 26, 2000 at 06:37:35PM -0400, Richards, Tom wrote:> Hello: > > This is a simple, I hope, question about the first example in section 3.6.4 > of the manual, "Writing R extensions." > > I'm using R 1.1.0, and below I list some easy code that I got from section > 3.6.4. When I try to compile the file out.c under NT 4, using VC++ 6.0, I > get the following error messages: > > Compiling... > out.c > Linking... > out.obj : error LNK2001: unresolved external symbol _Rf_unprotect > out.obj : error LNK2001: unresolved external symbol _Rf_protect > out.obj : error LNK2001: unresolved external symbol _Rf_allocMatrix > out.obj : error LNK2001: unresolved external symbol _Rf_length >My supposition is that you are not linking against the export library for R.dll (all these functions are there). Details on how this can be done with Visual C are in README.PACKAGES included in rw1010sp.zip. guido -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._