[Rcpp-devel] sourceCpp failing on windows whereas devtools::has_devel and devtools:::R works
romain at r-enthusiasts.com
romain at r-enthusiasts.com
Fri Oct 18 08:19:39 CEST 2013
Le 2013-10-17 16:49, JJ Allaire a écrit :
> I think the reason Dirks configuration worked is that he added Rtools
> to the path during installation. If Romain didnt do this, then
> sourceCpp goes looking for Rtools 2.15 or 2.16 (the initial
> development version for R 3.0) and doesnt 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.
Thanks JJ. I've applied the change to Rcpp11 too.
Indeed my client could not choose the option to change his PATH when
using Rtools installer because of some windows admin rights #bs. There
could have been other ways to fix it locally, and during the training
yesterday, using Rstudio was just fine. I just did not like the idea of
having Rtools installed, and usable (i.e. devtools could find it), but
not being able to use it from sourceCpp.
Romain
> On Thu, Oct 17, 2013 at 3:04 AM, <romain at r-enthusiasts.com [2]>
> 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/ [1]
>>
>> Using devtools:::R however, I manage to compile the file correctly:
>>
>> co
>>
>>> cpp::export]]
>>> + double foo(){
>>> +
>> 2;
>> + }
>> +
>> Sys.setenv( "PKG_CXXFLAGS" = Rcpp:::RcppCxxFlags() )
>> Sys.setenv( "PKG_LIBS" = Rcpp::
>>
>>> B 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&q
>> /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
>>
>> 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.
>>
>>> pp-devel" target="_blank">https://lists.r-forge.r-pr
>> -bin/mailman/listinfo/rcpp-devel
>
>
>
> Links:
> ------
> [1] http://cran.r-project.org/bin/windows/Rtools/
> [2] mailto:romain at r-enthusiasts.com
More information about the Rcpp-devel
mailing list