Subject: RE: [R] Looking for protect()
From: Richards, Tom (richards@pci.upmc.edu)
Date: Tue 27 Jun 2000 - 12:05:04 EST
Message-ID: <5B9B19C8A522D411A8EC00A0C99D6A9A02E54D@mail.nsabp.pitt.edu>
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@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);
}
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
This archive was generated by hypermail 2b25 : Mon 17 Jul 2000 - 12:33:24 EST