[R] Looking for protect()

Richards, Tom richards at pci.upmc.edu
Tue Jun 27 04:05:04 CEST 2000


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


More information about the R-help mailing list