[Rcpp-devel] sourceCpp failing on windows whereas devtools::has_devel and devtools:::R works

JJ Allaire jj.allaire at gmail.com
Thu Oct 17 16:49:07 CEST 2013


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.

J.J.


On Thu, Oct 17, 2013 at 3:04 AM, <romain at r-enthusiasts.com> wrote:

> Hello,
>
> On a windows machine where Rtools is installed and works, i.e. I get:
>
>  require(devtools)
>> has_devel()
>>
> "C:/R/R-3.0.2/bin/i386/R" --vanilla CMD SHLIB foo.c
>
> gcc -m32 -I"C:/R/R-30~1.2/include" -DNDEBUG
>  -I"C:/R/R-3.0.2/library/Rcpp/**include" -I"d:/RCompile/CRANpkg/**extralibs64/local/include"
>     -O3 -Wall  -std=gnu99 -mtune=core2 -c foo.c -o foo.o
> gcc -m32 -shared -s -static-libgcc -o foo.dll tmp.def foo.o
> C:/R/R-3.0.2/library/Rcpp/lib/**i386/libRcpp.a -Ld:/RCompile/CRANpkg/**extralibs64/local/lib/i386
> -Ld:/RCompile/CRANpkg/**extralibs64/local/lib -LC:/R/R-30~1.2/bin/i386 -lR
> [1] TRUE
>
>
> sourceCpp does not manage to find the tools correctly:
>
>  evalCpp( "1+1")
>>
>
> Error in sourceCpp(code = code, env = env, rebuild = rebuild, showOutput =
> showOutput,  :
>   Error 1 occurred building shared library.
>
> WARNING: The tools required to build C++ code for R were not found.
>
> Please download and install the appropriate version of Rtools:
>
> http://cran.r-project.org/bin/**windows/Rtools/<http://cran.r-project.org/bin/windows/Rtools/>
>
>
> Using devtools:::R however, I manage to compile the file correctly:
>
>  code <- '#include <Rcpp.h>
>>
> + using namespace Rcpp;
> +
> + // [[Rcpp::export]]
> + double foo(){
> +        return 2;
> + }
> + '
>
>> Sys.setenv( "PKG_CXXFLAGS" = Rcpp:::RcppCxxFlags() )
>> Sys.setenv( "PKG_LIBS" = Rcpp:::RcppLdFlags() )
>>
>> writeLines( code, "test.cpp" )
>> devtools:::R( "CMD SHLIB test.cpp", getwd() )
>>
> "C:/R/R-3.0.2/bin/i386/R" --vanilla CMD SHLIB test.cpp
>
> g++ -m32 -I"C:/R/R-30~1.2/include" -DNDEBUG     -I"d:/RCompile/CRANpkg/**extralibs64/local/include"
>  -IC:/R/R-3.0.2/library/Rcpp/**include   -O2 -Wall  -mtune=core2 -c
> test.cpp -o test.o
> g++ -m32 -shared -s -static-libgcc -o test.dll tmp.def test.o
> C:/R/R-3.0.2/library/Rcpp/lib/**i386/libRcpp.a -Ld:/RCompile/CRANpkg/**extralibs64/local/lib/i386
> -Ld:/RCompile/CRANpkg/**extralibs64/local/lib -LC:/R/R-30~1.2/bin/i386 -lR
>
>
> 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:
>
> cmd <- paste(R.home(component = "bin"), .Platform$file.sep,
>             "R ", "CMD SHLIB ", "-o ", shQuote(context$**dynlibFilename),
>             " ", ifelse(rebuild, "--preclean ", ""), shQuote(context$**
> cppSourceFilename),
>             sep = "")
>
> Romain
>
>  version
>>
>                _
> platform       i386-w64-mingw32
> arch           i386
> os             mingw32
> system         i386, mingw32
> status
> major          3
> minor          0.2
> year           2013
> month          09
> day            25
> svn rev        63987
> language       R
> version.string R version 3.0.2 (2013-09-25)
> nickname       Frisbee Sailing
>
>> packageDescription("Rcpp")$**Version
>>
> [1] "0.10.5"
>
>
>
>
>
> ______________________________**_________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-**project.org<Rcpp-devel at lists.r-forge.r-project.org>
> https://lists.r-forge.r-**project.org/cgi-bin/mailman/**
> listinfo/rcpp-devel<https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20131017/51c0a17e/attachment.html>


More information about the Rcpp-devel mailing list