<div dir="ltr">I think the reason Dirk's configuration worked is that he added Rtools to the path during installation. If Romain didn't do this, then sourceCpp goes looking for Rtools 2.15 or 2.16 (the initial development version for R 3.0) and doesn't find it. I just committed a change that includes R 3.0 and R 3.1 in the whitelist of Rtools versions we know work correctly.<div>
<br></div><div>J.J.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Oct 17, 2013 at 3:04 AM,  <span dir="ltr"><<a href="mailto:romain@r-enthusiasts.com" target="_blank">romain@r-enthusiasts.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
On a windows machine where Rtools is installed and works, i.e. I get:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
require(devtools)<br>
has_devel()<br>
</blockquote>
"C:/R/R-3.0.2/bin/i386/R" --vanilla CMD SHLIB foo.c<br>
<br>
gcc -m32 -I"C:/R/R-30~1.2/include" -DNDEBUG    -I"C:/R/R-3.0.2/library/Rcpp/<u></u>include" -I"d:/RCompile/CRANpkg/<u></u>extralibs64/local/include"     -O3 -Wall  -std=gnu99 -mtune=core2 -c foo.c -o foo.o<br>

gcc -m32 -shared -s -static-libgcc -o foo.dll tmp.def foo.o C:/R/R-3.0.2/library/Rcpp/lib/<u></u>i386/libRcpp.a -Ld:/RCompile/CRANpkg/<u></u>extralibs64/local/lib/i386 -Ld:/RCompile/CRANpkg/<u></u>extralibs64/local/lib -LC:/R/R-30~1.2/bin/i386 -lR<br>

[1] TRUE<br>
<br>
<br>
sourceCpp does not manage to find the tools correctly:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
evalCpp( "1+1")<br>
</blockquote>
<br>
Error in sourceCpp(code = code, env = env, rebuild = rebuild, showOutput = showOutput,  :<br>
  Error 1 occurred building shared library.<br>
<br>
WARNING: The tools required to build C++ code for R were not found.<br>
<br>
Please download and install the appropriate version of Rtools:<br>
<br>
<a href="http://cran.r-project.org/bin/windows/Rtools/" target="_blank">http://cran.r-project.org/bin/<u></u>windows/Rtools/</a><br>
<br>
<br>
Using devtools:::R however, I manage to compile the file correctly:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
code <- '#include <Rcpp.h><br>
</blockquote>
+ using namespace Rcpp;<br>
+<br>
+ // [[Rcpp::export]]<br>
+ double foo(){<br>
+        return 2;<br>
+ }<br>
+ '<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Sys.setenv( "PKG_CXXFLAGS" = Rcpp:::RcppCxxFlags() )<br>
Sys.setenv( "PKG_LIBS" = Rcpp:::RcppLdFlags() )<br>
<br>
writeLines( code, "test.cpp" )<br>
devtools:::R( "CMD SHLIB test.cpp", getwd() )<br>
</blockquote>
"C:/R/R-3.0.2/bin/i386/R" --vanilla CMD SHLIB test.cpp<br>
<br>
g++ -m32 -I"C:/R/R-30~1.2/include" -DNDEBUG     -I"d:/RCompile/CRANpkg/<u></u>extralibs64/local/include"  -IC:/R/R-3.0.2/library/Rcpp/<u></u>include   -O2 -Wall  -mtune=core2 -c test.cpp -o test.o<br>

g++ -m32 -shared -s -static-libgcc -o test.dll tmp.def test.o C:/R/R-3.0.2/library/Rcpp/lib/<u></u>i386/libRcpp.a -Ld:/RCompile/CRANpkg/<u></u>extralibs64/local/lib/i386 -Ld:/RCompile/CRANpkg/<u></u>extralibs64/local/lib -LC:/R/R-30~1.2/bin/i386 -lR<br>

<br>
<br>
So perhaps we can borrow some wisdom out of devtools to make sourceCpp work. As one can expect, the code from sourceCpp that fails is these lines:<br>
<br>
cmd <- paste(R.home(component = "bin"), .Platform$file.sep,<br>
            "R ", "CMD SHLIB ", "-o ", shQuote(context$<u></u>dynlibFilename),<br>
            " ", ifelse(rebuild, "--preclean ", ""), shQuote(context$<u></u>cppSourceFilename),<br>
            sep = "")<br>
<br>
Romain<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
version<br>
</blockquote>
               _<br>
platform       i386-w64-mingw32<br>
arch           i386<br>
os             mingw32<br>
system         i386, mingw32<br>
status<br>
major          3<br>
minor          0.2<br>
year           2013<br>
month          09<br>
day            25<br>
svn rev        63987<br>
language       R<br>
version.string R version 3.0.2 (2013-09-25)<br>
nickname       Frisbee Sailing<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
packageDescription("Rcpp")$<u></u>Version<br>
</blockquote>
[1] "0.10.5"<br>
<br>
<br>
<br>
<br>
<br>
______________________________<u></u>_________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org" target="_blank">Rcpp-devel@lists.r-forge.r-<u></u>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-<u></u>project.org/cgi-bin/mailman/<u></u>listinfo/rcpp-devel</a><br>
</blockquote></div><br></div>