<!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 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&nbsp;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&nbsp;below I&nbsp;list some easy code that I got from section 3.6.4.&nbsp; 
When I try to compile&nbsp;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.&nbsp; Hopefully, I am just missing them.&nbsp; Can 
anyone help?</SPAN></FONT><FONT face=Arial size=2><SPAN 
class=692332222-26062000>&nbsp; Here is the file out.c:</SPAN></FONT></P>
<P><FONT size=2>#include &lt;R.h&gt;</FONT></P>
<P><FONT size=2>#include &lt;Rinternals.h&gt;</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 &lt; nx; i++) {</FONT></P>
<P><FONT size=2>tmp = REAL(x)[i];</FONT></P>
<P><FONT size=2>for(j = 0; j &lt; 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></BODY></HTML>