Reputation: 566
I am having a really hard time trying to make Rcpp work on my Windows. I downloaded Rtools and I have changed the path to
c:\Rtools\bin;c:\Rtools\gcc-4.6.3\bin;c:\Program Files\R\R-3.0.2\bin\x64;[others]
I have then taken a really simple c++ file (new.cpp) that goes like this
include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
int timesTwo(int x) {
return x * 2;
}
I then go on the Powershell and as suggested on Seamless R and C++ Integration with Rcpp by D. Eddelbuettel (Chap. 2) I try to compile the code
PS C:\Users\RXD308\pgmcpp> PKG_CXXFLAGS='Rscript -e 'Rcpp:::CxxFlags()''\ PKG_LIBS='Rscript -e 'Rcpp:::LdFlags()''\ RCMD SHLIB new.cpp
Obtaining the error
An expression was expected after '('.
At line:1 char:43
+ PKG_CXXFLAGS='Rscript -e 'Rcpp:::CxxFlags( <<<< )''\ PKG_LIBS='Rscript -e 'Rcpp:::LdFlags()''\ RCMD SHLIB new.cpp
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : ExpectedExpression
Two last things
I have MinGW up and working on my computer (g++ 4.6)
I think I have a major problem with the R command in the powershell. In facts, as I access the powershell and I type "R --version" I obtain this error
Invoke-History : Cannot locate history for commandline --version.
At line:1 char:2
+ R <<<< --version
+ CategoryInfo : ObjectNotFound: (--version:String) [Invoke-History], ArgumentException
+ FullyQualifiedErrorId : InvokeHistoryNoHistoryForCommandline,Microsoft.PowerShell.Commands.InvokeHistoryCommand
Upvotes: 0
Views: 1208
Reputation: 368409
That is a shell error:
PKG_CXXFLAGS='Rscript -e 'Rcpp:::CxxFlags()''
PKG_LIBS='Rscript -e 'Rcpp:::LdFlags()''
RCMD SHLIB new.cpp
as you have single ticks inside single ticks. Look more carefully at page 24 and see the difference between backward-facing ticks and forward-facing ticks. Backward implies execution.
When working through this, you can avoid these second level of indirection by just executing something like Rcpp::LdFlags()
in your R session and the just copy the resulting string over into Makevars.
This will help you compile your code, which is the first order of business.
For creating distributable Makevars, you can then look more carefully at published solutions.
Edit: Make sure you can walk before you run. Start with something like this
C:\>R CMD config CXXFLAGS
-O2 -Wall -mtune=core2
C:\>
and then get towards Rscript
invoking Rcpp functions as shown. Maybe you have powershell issues; I just did this in cmd.exe
.
Upvotes: 2