<div><font class="Apple-style-span" color="#ff0000">Thanks for your reply.</font></div><div><font class="Apple-style-span" color="#ff0000"><br></font></div><div><font class="Apple-style-span" color="#ff0000">Here is the response of 'Hello World' program:</font></div>
<div><br></div><div><div><div><div>> src='#include <iostream></div><div>+ using namespace std;</div><div>+ void main()</div><div>+ {</div><div>+ cout << "Hello World!" << endl;</div><div>
+ cout << "Welcome to C++ Programming" << endl;</div><div>+ }'</div><div>> </div><div>> fx <- cxxfunction(src,plugin = "Rcpp",verbose=T)</div><div> >> setting environment variables: </div>
<div>PKG_LIBS = C:/R/Rsoft/library/Rcpp/lib/i386/libRcpp.a</div><div><br></div><div> >> LinkingTo : Rcpp</div><div>CLINK_CPPFLAGS = -I"C:/R/Rsoft/library/Rcpp/include" </div><div><br></div><div> >> Program source :</div>
<div><br></div><div> 1 : </div><div> 2 : // includes from the plugin</div><div> 3 : </div><div> 4 : #include <Rcpp.h></div><div> 5 : </div><div> 6 : </div><div> 7 : #ifndef BEGIN_RCPP</div><div> 8 : #define BEGIN_RCPP</div>
<div> 9 : #endif</div><div> 10 : </div><div> 11 : #ifndef END_RCPP</div><div> 12 : #define END_RCPP</div><div> 13 : #endif</div><div> 14 : </div><div> 15 : using namespace Rcpp;</div><div> 16 : </div><div> 17 : </div>
<div> 18 : // user includes</div><div> 19 : </div><div> 20 : </div><div> 21 : // declarations</div><div> 22 : extern "C" {</div><div> 23 : SEXP file3a1c304e( ) ;</div><div> 24 : }</div><div> 25 : </div><div>
26 : // definition</div><div> 27 : </div><div> 28 : SEXP file3a1c304e( ){</div><div> 29 : BEGIN_RCPP</div><div> 30 : </div><div> 31 : END_RCPP</div><div> 32 : }</div><div> 33 : </div><div> 34 : </div><div>Compilation argument:</div>
<div> C:/R/Rsoft/bin/i386/R CMD SHLIB file3a1c304e.cpp 2> file3a1c304e.cpp.err.txt </div><div>g++ -I"C:/R/Rsoft/include" -I"C:/R/Rsoft/library/Rcpp/include" -O2 -Wall -c file3a1c304e.cpp -o file3a1c304e.o</div>
<div>g++ -shared -s -static-libgcc -o file3a1c304e.dll tmp.def file3a1c304e.o C:/R/Rsoft/library/Rcpp/lib/i386/libRcpp.a -LC:/R/Rsoft/bin/i386 -lR</div><div>cygwin warning:</div><div> MS-DOS style path detected: C:/R/Rsoft/etc/i386/Makeconf</div>
<div> Preferred POSIX equivalent is: /cygdrive/c/R/Rsoft/etc/i386/Makeconf</div><div> CYGWIN environment variable option "nodosfilewarning" turns off this warning.</div><div> Consult the user's guide for more details about POSIX paths:</div>
<div> <a href="http://cygwin.com/cygwin-ug-net/using.html#using-pathnames">http://cygwin.com/cygwin-ug-net/using.html#using-pathnames</a></div><div>Error in as.function.default(c(value, if (is.null(bd) || is.list(bd)) list(bd) else bd), : </div>
<div> invalid formal argument list for "function"</div></div></div></div><div><br></div><div><font class="Apple-style-span" color="#ff0000">Here, I also tried the test by Hadley,</font></div><div><br></div><div>
<div>_devel()</div><div>cygwin warning:</div><div> MS-DOS style path detected: C:/R/Rsoft/etc/i386/Makeconf</div><div> Preferred POSIX equivalent is: /cygdrive/c/R/Rsoft/etc/i386/Makeconf</div><div> CYGWIN environment variable option "nodosfilewarning" turns off this warning.</div>
<div> Consult the user's guide for more details about POSIX paths:</div><div> <a href="http://cygwin.com/cygwin-ug-net/using.html#using-pathnames">http://cygwin.com/cygwin-ug-net/using.html#using-pathnames</a></div>
<div>gcc -I"C:/R/Rsoft/include" -I"C:/R/Rsoft/library/Rcpp/include" -O3 -Wall -std=gnu99 -c foo.c -o foo.o</div><div>gcc -shared -s -static-libgcc -o foo.dll tmp.def foo.o C:/R/Rsoft/library/Rcpp/lib/i386/libRcpp.a -LC:/R/Rsoft/bin/i386 -lR</div>
<div>[1] TRUE</div></div><div><br></div><div>Sorry that I don't really get it how to rebuild R packages from source.</div><div><br></div>Thanks,<div><br></div><div>Kent<br><br><div class="gmail_quote">On Thu, Oct 13, 2011 at 5:11 PM, Hadley Wickham <span dir="ltr"><<a href="mailto:hadley@rice.edu">hadley@rice.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">> My best guess is that you have not installed the Rtools correctly. Can you<br>
> compile a simple 'hello, world' example in C or C++? Can you rebuild R<br>
> packages from source?<br>
<br>
</div>I wrote an function to check that you have a valid R development<br>
environment (with help from Simon Urbanek) for devtools. See code<br>
below - and check with has_devel()<br>
<br>
Hadley<br>
<br>
<br>
has_devel <- function() {<br>
foo_path <- file.path(tempdir(), "foo.c")<br>
<br>
cat("void foo(int *bar) { *bar=1; }\n", file = foo_path)<br>
on.exit(unlink(foo_path))<br>
<br>
R("CMD SHLIB foo.c", tempdir())<br>
dylib <- file.path(tempdir(), paste("foo", .Platform$dynlib.ext, sep=''))<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(".C", list("foo",0L))[[1]] == 1L)<br>
TRUE<br>
}<br>
<br>
R <- function(options, path = tempdir()) {<br>
r_path <- shQuote(file.path(R.home("bin"), "R"))<br>
in_dir(path, system_check(paste(r_path, options)))<br>
}<br>
<br>
system_check <- function(cmd) {<br>
res <- system(cmd)<br>
if (res != 0) {<br>
stop("Command failed (", res, ")", call. = FALSE)<br>
}<br>
invisible(TRUE)<br>
}<br>
<br>
in_dir <- function(dir, code) {<br>
cur <- getwd()<br>
setwd(dir)<br>
on.exit(setwd(cur))<br>
<br>
force(code)<br>
}<br>
<font color="#888888"><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>
</font><div><div></div><div class="h5">_______________________________________________<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>
</div></div></blockquote></div><br></div>