Perhaps you can try updating your Rcpp? The latest version is <span style="font-family:Times;font-size:medium;background-color:rgb(255,255,255)">0.10.3. But I don't know if that's the reason why sourceCpp is not in your Rcpp library.</span><br clear="all">

<div><br></div><div><br></div><br><div class="gmail_quote">On Thu, May 23, 2013 at 9:46 PM, Peng Yu <span dir="ltr"><<a href="mailto:pengyu.ut@gmail.com" target="_blank">pengyu.ut@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Hi Xiao,<br>
<br>
Where is sourceCpp? I don't see it in my Rcpp.<br>
<br>
~/dvcs_src/rcpp-gallery/src$ R<br>
> library(Rcpp)<br>
> sourceCpp<br>
Error: object 'sourceCpp' not found<br>
> library(Rcpp)<br>
> sessionInfo()<br>
R version 3.0.0 (2013-04-03)<br>
Platform: x86_64-apple-darwin10.8.0 (64-bit)<br>
<br>
locale:<br>
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8<br>
<br>
attached base packages:<br>
[1] stats     graphics  grDevices utils     datasets  methods   base<br>
<br>
other attached packages:<br>
[1] Rcpp_0.9.13<br>
<div class="HOEnZb"><div class="h5"><br>
On Thu, May 23, 2013 at 11:27 PM, Xiao He <<a href="mailto:praguewatermelon@gmail.com">praguewatermelon@gmail.com</a>> wrote:<br>
> If you compile it from within R using sourceCpp("cpp_file_name.cpp "). Or if<br>
> you use the package inline, you can do the following inside R.<br>
><br>
> cppFunction('<br>
>       NumericVector callFunction(NumericVector x, Function f) {<br>
>            NumericVector res = f(x);<br>
>            return res;<br>
>      }'<br>
>  )<br>
><br>
> Both methods let you directly call the function callFunction(x, f) (without<br>
> having to use .Call())<br>
><br>
> callFunction(rnorm(30), sum)<br>
><br>
><br>
><br>
><br>
><br>
> On Thu, May 23, 2013 at 9:14 PM, Peng Yu <<a href="mailto:pengyu.ut@gmail.com">pengyu.ut@gmail.com</a>> wrote:<br>
>><br>
>> Hi,<br>
>><br>
>> I'm able to compile 2013-01-05-r-function-from-c++.cpp to the .so<br>
>> file. But I'm not able to call "callFunction" in R does anybody know<br>
>> what the correct way is to call R functions in C++? Thanks.<br>
>><br>
>> > dyn.load('2013-01-05-r-function-from-c++.so')<br>
>> > x <- rnorm(1e5)<br>
>> > .Call('callFunction', x, fivenum)<br>
>> Error in .Call("callFunction", x, fivenum) :<br>
>>   C symbol name "callFunction" not in load table<br>
>> > callFunction(x, fivenum)<br>
>> Error: could not find function "callFunction"<br>
>><br>
>> --<br>
>> Regards,<br>
>> Peng<br>
>> _______________________________________________<br>
>> Rcpp-devel mailing list<br>
>> <a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>
>> <a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br>
><br>
><br>
<br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">--<br>
Regards,<br>
Peng<br>
</font></span></blockquote></div><br>