<div class="gmail_quote"><div class="im">| Hi, Dirk,<br>
|<br>
</div><div class="im">| Sorry to disturb you again.<br>
|<br>
| Actually, I am also very interested in how to call back the R commands in<br>
| &#39;cxxfunction&#39;. Do you have some examples or tutorial about this?  <br>
<br>
</div>Please keep questions on the mailing list.<br>
<div><div></div><div class="h5"><br>
Dirk<br>
<br>
|<br>
| Thank you very much.<br>
|<br>
| Best regards,<br>
|<br>
| Kent<br>
|<br>
|<br>
| On Fri, Oct 14, 2011 at 4:39 PM, Dirk Eddelbuettel &lt;<a href="mailto:edd@debian.org">edd@debian.org</a>&gt; wrote:<br>
|<br>
|<br>
|     Hi Kent,<br>
|<br>
|     On 14 October 2011 at 16:00, Jian Kang wrote:<br>
|     | Hi, Dirk,<br>
|     |<br>
|     | Sorry for delay. <br>
|     |<br>
|     | I tried to install the R and Rtools again, and run the program again,<br>
|     then it<br>
|     | works. <br>
|<br>
|     Excellent!<br>
|<br>
|     | But here is some warnings, I am not sure whether this is OK in the<br>
|     future.<br>
|     |<br>
|     | Compilation argument:<br>
|     |  C:/R/Rsoft/bin/i386/R CMD SHLIB file7e446574.cpp 2&gt;<br>
|     | file7e446574.cpp.err.txt <br>
|     | g++ -I&quot;C:/R/Rsoft/include&quot;    -I&quot;C:/R/Rsoft/library/Rcpp/include&quot;    <br>
|      -O2<br>
|     | -Wall  -c file7e446574.cpp -o file7e446574.o<br>
|     | g++ -shared -s -static-libgcc -o file7e446574.dll tmp.def file7e446574.o<br>
|     C:/R/<br>
|     | Rsoft/library/Rcpp/lib/i386/libRcpp.a -LC:/R/Rsoft/bin/i386 -lR<br>
|     | cygwin warning:<br>
|     |   MS-DOS style path detected: C:/R/Rsoft/etc/i386/Makeconf<br>
|     |   Preferred POSIX equivalent is: /cygdrive/c/R/Rsoft/etc/i386/Makeconf<br>
|     |   CYGWIN environment variable option &quot;nodosfilewarning&quot; turns off this<br>
|     | warning.<br>
|     |   Consult the user&#39;s guide for more details about POSIX paths:<br>
|     |     <a href="http://cygwin.com/cygwin-ug-net/using.html#using-pathnames" target="_blank">http://cygwin.com/cygwin-ug-net/using.html#using-pathnames</a><br>
|<br>
|     That started with more recent Cygwin / MinGW versions.  Google for this, I<br>
|     think there were tricks to turn it off. This came up on r-help once or<br>
|     twice<br>
|     too.<br>
|<br>
|     But to reiterate: it is just a warning, and it has nothing to do with Rcpp.<br>
|<br>
|     Dirk<br>
|<br>
|<br>
|     | Thank you very much.<br>
|     |<br>
|     | Best,<br>
|     |<br>
|     | Kent<br>
|     |<br>
|     |<br>
|     | On Thu, Oct 13, 2011 at 6:46 PM, Dirk Eddelbuettel &lt;<a href="mailto:edd@debian.org">edd@debian.org</a>&gt;<br>
|     wrote:<br>
|     |<br>
|     |<br>
|     |     On 13 October 2011 at 18:15, Jian Kang wrote:<br>
|     |     | Thanks for your reply.<br>
|     |     |<br>
|     |     | Here is the response of &#39;Hello World&#39; program:<br>
|     |     |<br>
|     |     | &gt; src=&#39;#include &lt;iostream&gt;<br>
|     |     | + using namespace std;<br>
|     |     | + void main()<br>
|     |     | + {<br>
|     |     | + cout &lt;&lt; &quot;Hello World!&quot; &lt;&lt; endl;<br>
|     |     | + cout &lt;&lt; &quot;Welcome to C++ Programming&quot; &lt;&lt; endl;<br>
|     |     | + }&#39;<br>
|     |     | &gt; <br>
|     |     | &gt; fx &lt;- cxxfunction(src,plugin = &quot;Rcpp&quot;,verbose=T)<br>
|     |<br>
|     |     PBKAC -- wrong call of cxxfunction().  You can see below how the<br>
|     generated<br>
|     |     code does *not* include your actual function.<br>
|     |<br>
|     |     The correct idiom is<br>
|     |<br>
|     |        fx &lt;- cxxfunction(signature(), body=src,plugin =<br>
|     &quot;Rcpp&quot;,verbose=TRUE)<br>
|     |<br>
|     |     Dirk<br>
|     |<br>
|     |<br>
|     |     |  &gt;&gt; setting environment variables: <br>
|     |     | PKG_LIBS =  C:/R/Rsoft/library/Rcpp/lib/i386/libRcpp.a<br>
|     |     |<br>
|     |     |  &gt;&gt; LinkingTo : Rcpp<br>
|     |     | CLINK_CPPFLAGS =  -I&quot;C:/R/Rsoft/library/Rcpp/include&quot; <br>
|     |     |<br>
|     |     |  &gt;&gt; Program source :<br>
|     |     |<br>
|     |     |    1 : <br>
|     |     |    2 : // includes from the plugin<br>
|     |     |    3 : <br>
|     |     |    4 : #include &lt;Rcpp.h&gt;<br>
|     |     |    5 : <br>
|     |     |    6 : <br>
|     |     |    7 : #ifndef BEGIN_RCPP<br>
|     |     |    8 : #define BEGIN_RCPP<br>
|     |     |    9 : #endif<br>
|     |     |   10 : <br>
|     |     |   11 : #ifndef END_RCPP<br>
|     |     |   12 : #define END_RCPP<br>
|     |     |   13 : #endif<br>
|     |     |   14 : <br>
|     |     |   15 : using namespace Rcpp;<br>
|     |     |   16 : <br>
|     |     |   17 : <br>
|     |     |   18 : // user includes<br>
|     |     |   19 : <br>
|     |     |   20 : <br>
|     |     |   21 : // declarations<br>
|     |     |   22 : extern &quot;C&quot; {<br>
|     |     |   23 : SEXP file3a1c304e( ) ;<br>
|     |     |   24 : }<br>
|     |     |   25 : <br>
|     |     |   26 : // definition<br>
|     |     |   27 : <br>
|     |     |   28 : SEXP file3a1c304e(  ){<br>
|     |     |   29 : BEGIN_RCPP<br>
|     |     |   30 : <br>
|     |     |   31 : END_RCPP<br>
|     |     |   32 : }<br>
|     |     |   33 : <br>
|     |     |   34 : <br>
|     |     | Compilation argument:<br>
|     |     |  C:/R/Rsoft/bin/i386/R CMD SHLIB file3a1c304e.cpp 2&gt;<br>
|     |     | file3a1c304e.cpp.err.txt <br>
|     |     | g++ -I&quot;C:/R/Rsoft/include&quot;    -I&quot;C:/R/Rsoft/library/Rcpp/<br>
|     include&quot;    <br>
|     |      -O2<br>
|     |     | -Wall  -c file3a1c304e.cpp -o file3a1c304e.o<br>
|     |     | g++ -shared -s -static-libgcc -o file3a1c304e.dll tmp.def<br>
|     file3a1c304e.o<br>
|     |     C:/R/<br>
|     |     | Rsoft/library/Rcpp/lib/i386/libRcpp.a -LC:/R/Rsoft/bin/i386 -lR<br>
|     |     | cygwin warning:<br>
|     |     |   MS-DOS style path detected: C:/R/Rsoft/etc/i386/Makeconf<br>
|     |     |   Preferred POSIX equivalent is: /cygdrive/c/R/Rsoft/etc/i386/<br>
|     Makeconf<br>
|     |     |   CYGWIN environment variable option &quot;nodosfilewarning&quot; turns<br>
|     off this<br>
|     |     | warning.<br>
|     |     |   Consult the user&#39;s guide for more details about POSIX paths:<br>
|     |     |     <a href="http://cygwin.com/cygwin-ug-net/using.html#using-pathnames" target="_blank">http://cygwin.com/cygwin-ug-net/using.html#using-pathnames</a><br>
|     |     | Error in as.function.default(c(value, if (is.null(bd) || is.list<br>
|     (bd))<br>
|     |     list(bd)<br>
|     |     | else bd),  : <br>
|     |     |   invalid formal argument list for &quot;function&quot;<br>
|     |     |<br>
|     |     | Here, I also tried the test by Hadley,<br>
|     |     |<br>
|     |     | _devel()<br>
|     |     | cygwin warning:<br>
|     |     |   MS-DOS style path detected: C:/R/Rsoft/etc/i386/Makeconf<br>
|     |     |   Preferred POSIX equivalent is: /cygdrive/c/R/Rsoft/etc/i386/<br>
|     Makeconf<br>
|     |     |   CYGWIN environment variable option &quot;nodosfilewarning&quot; turns<br>
|     off this<br>
|     |     | warning.<br>
|     |     |   Consult the user&#39;s guide for more details about POSIX paths:<br>
|     |     |     <a href="http://cygwin.com/cygwin-ug-net/using.html#using-pathnames" target="_blank">http://cygwin.com/cygwin-ug-net/using.html#using-pathnames</a><br>
|     |     | gcc -I&quot;C:/R/Rsoft/include&quot;    -I&quot;C:/R/Rsoft/library/Rcpp/<br>
|     include&quot;    <br>
|     |      -O3<br>
|     |     | -Wall  -std=gnu99 -c foo.c -o foo.o<br>
|     |     | gcc -shared -s -static-libgcc -o foo.dll tmp.def foo.o C:/R/Rsoft<br>
|     /library<br>
|     |     /Rcpp/<br>
|     |     | lib/i386/libRcpp.a -LC:/R/Rsoft/bin/i386 -lR<br>
|     |     | [1] TRUE<br>
|     |     |<br>
|     |     | Sorry that I don&#39;t really get it how to rebuild R packages from<br>
|     source.<br>
|     |     |<br>
|     |     | Thanks,<br>
|     |     |<br>
|     |     | Kent<br>
|     |     |<br>
|     |     | On Thu, Oct 13, 2011 at 5:11 PM, Hadley Wickham &lt;<a href="mailto:hadley@rice.edu">hadley@rice.edu</a>&gt;<br>
|     wrote:<br>
|     |     |<br>
|     |     |     &gt; My best guess is that you have not installed the Rtools<br>
|     |     correctly.  Can<br>
|     |     |     you<br>
|     |     |     &gt; compile a simple &#39;hello, world&#39; example in C or C++?<br>
|      Can you<br>
|     |     rebuild R<br>
|     |     |     &gt; packages from source?<br>
|     |     |<br>
|     |     |     I wrote an function to check that you have a valid R<br>
|     development<br>
|     |     |     environment (with help from Simon Urbanek) for devtools.<br>
|      See code<br>
|     |     |     below - and check with has_devel()<br>
|     |     |<br>
|     |     |     Hadley<br>
|     |     |<br>
|     |     |<br>
|     |     |     has_devel &lt;- function() {<br>
|     |     |      foo_path &lt;- file.path(tempdir(), &quot;foo.c&quot;)<br>
|     |     |<br>
|     |     |      cat(&quot;void foo(int *bar) { *bar=1; }\n&quot;, file = foo_path)<br>
|     |     |      on.exit(unlink(foo_path))<br>
|     |     |<br>
|     |     |      R(&quot;CMD SHLIB foo.c&quot;, tempdir())<br>
|     |     |      dylib &lt;- file.path(tempdir(), paste(&quot;foo&quot;,<br>
|     .Platform$dynlib.ext,<br>
|     |     sep=&#39;&#39;))<br>
|     |     |      on.exit(unlink(dylib), add = TRUE)<br>
|     |     |<br>
|     |     |      dyn.load(dylib)<br>
|     |     |      on.exit(dyn.unload(dylib), add = TRUE)<br>
|     |     |<br>
|     |     |      stopifnot(do.call(&quot;.C&quot;, list(&quot;foo&quot;,0L))[[1]] == 1L)<br>
|     |     |      TRUE<br>
|     |     |     }<br>
|     |     |<br>
|     |     |     R &lt;- function(options, path = tempdir()) {<br>
|     |     |      r_path &lt;- shQuote(file.path(R.home(&quot;bin&quot;), &quot;R&quot;))<br>
|     |     |      in_dir(path, system_check(paste(r_path, options)))<br>
|     |     |     }<br>
|     |     |<br>
|     |     |     system_check &lt;- function(cmd) {<br>
|     |     |      res &lt;- system(cmd)<br>
|     |     |      if (res != 0) {<br>
|     |     |        stop(&quot;Command failed (&quot;, res, &quot;)&quot;, call. = FALSE)<br>
|     |     |      }<br>
|     |     |      invisible(TRUE)<br>
|     |     |     }<br>
|     |     |<br>
|     |     |     in_dir &lt;- function(dir, code) {<br>
|     |     |      cur &lt;- getwd()<br>
|     |     |      setwd(dir)<br>
|     |     |      on.exit(setwd(cur))<br>
|     |     |<br>
|     |     |      force(code)<br>
|     |     |     }<br>
|     |     |<br>
|     |     |     --<br>
|     |     |     Assistant Professor / Dobelman Family Junior Chair<br>
|     |     |     Department of Statistics / Rice University<br>
|     |     |     <a href="http://had.co.nz/" target="_blank">http://had.co.nz/</a><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/" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/</a><br>
|     listinfo/<br>
|     |     rcpp-devel<br>
|     |     |<br>
|     |     |<br>
|     |<br>
|     |     --<br>
|     |     &quot;Outside of a dog, a book is a man&#39;s best friend. Inside of a dog,<br>
|     it is<br>
|     |     too<br>
|     |     dark to read.&quot; -- Groucho Marx<br>
|     |<br>
|     |<br>
|<br>
|     --<br>
|     &quot;Outside of a dog, a book is a man&#39;s best friend. Inside of a dog, it is<br>
|     too<br>
|     dark to read.&quot; -- Groucho Marx<br>
|<br>
|<br>
<br>
--<br>
&quot;Outside of a dog, a book is a man&#39;s best friend. Inside of a dog, it is too<br>
dark to read.&quot; -- Groucho Marx<br>
</div></div></div><br>