<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META content="MSHTML 5.00.2314.1000" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT color=#0000ff face=Arial size=2><SPAN class=530140602-27062000>Sorry
to bother you: the functions are in memory.c, in the main src
subdirectory.</SPAN></FONT></DIV>
<BLOCKQUOTE
style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px">
<DIV align=left class=OutlookMessageHeader dir=ltr><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B> Richards, Tom
<BR><B>Sent:</B> Monday, June 26, 2000 6:38 PM<BR><B>To:</B>
r-help@stat.math.ethz.ch<BR><B>Subject:</B> [R] Looking for
protect()<BR><BR></DIV></FONT>
<DIV><FONT face=CMTT10><FONT face=CMTT10>
<P><FONT face=Arial size=2><SPAN
class=692332222-26062000>Hello:</SPAN></FONT></P>
<P><FONT face=Arial size=2><SPAN class=692332222-26062000>This is a simple, I
hope, question about the first example in section 3.6.4 of the manual,
"Writing R extensions."</SPAN></FONT></P>
<P><FONT face=Arial size=2><SPAN class=692332222-26062000>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:</SPAN></FONT></P>
<P><FONT face=Arial size=2><SPAN
class=692332222-26062000>Compiling...<BR>out.c<BR>Linking...<BR>out.obj :
error LNK2001: unresolved external symbol _Rf_unprotect<BR>out.obj : error
LNK2001: unresolved external symbol _Rf_protect<BR>out.obj : error LNK2001:
unresolved external symbol _Rf_allocMatrix<BR>out.obj : error LNK2001:
unresolved external symbol _Rf_length</SPAN></FONT></P>
<P><FONT face=Arial size=2><SPAN class=692332222-26062000>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:</SPAN></FONT></P>
<P><FONT face=Arial size=2><SPAN
class=692332222-26062000>Compiling...<BR>out.c<BR>Linking...<BR>out.obj :
error LNK2001: unresolved external symbol _unprotect<BR>out.obj : error
LNK2001: unresolved external symbol _protect<BR>out.obj : error LNK2001:
unresolved external symbol _allocMatrix<BR>out.obj : error LNK2001: unresolved
external symbol _length</SPAN></FONT></P>
<P><FONT face=Arial size=2><SPAN class=692332222-26062000>I cannot seem to
find these 4 functions anywhere. Hopefully, I am just missing
them. Can anyone help?</SPAN></FONT><FONT face=Arial size=2><SPAN
class=692332222-26062000> Here is the file out.c:</SPAN></FONT></P>
<P><FONT size=2>#include <R.h></FONT></P>
<P><FONT size=2>#include <Rinternals.h></FONT></P></FONT>
<P><FONT size=2>SEXP out(SEXP x, SEXP y)</FONT></P>
<P><FONT size=2>{</FONT></P>
<P><FONT size=2>int i, j, nx, ny;</FONT></P>
<P><FONT size=2>double tmp;</FONT></P>
<P><FONT size=2>SEXP ans;</FONT></P>
<P><FONT size=2>nx = length(x); ny = length(y);</FONT></P>
<P><FONT size=2>PROTECT(ans = allocMatrix(REALSXP, nx, ny));</FONT></P>
<P><FONT size=2>for(i = 0; i < nx; i++) {</FONT></P>
<P><FONT size=2>tmp = REAL(x)[i];</FONT></P>
<P><FONT size=2>for(j = 0; j < ny; j++)</FONT></P>
<P><FONT size=2>REAL(ans)[i + nx*j] = tmp * REAL(y)[j];</FONT></P>
<P><FONT size=2>}</FONT></P>
<P><FONT size=2>UNPROTECT(1);</FONT></P>
<P><FONT size=2>return(ans);</FONT></P>
<P><FONT size=2>}</FONT></P></FONT></DIV></BLOCKQUOTE></BODY></HTML>