heavy rocker dude
heavy rocker dude

Reputation: 2301

Using Visual C++ with R

I am wondering if there was a workaround for using the R package Rcpp within a Visual C++ project within Visual Studio. According to the Rcpp FAQ, this is not possible. I also came across another R package called R.NET. Can this only work with C# but there seems to be no examples from within Visual C++? Is there another option for this that I am missing? Even if I am forced to work with C#, can anyone envision latency issues with this for a high frequency trading environment? Thanks for any feedback

Upvotes: 1

Views: 4509

Answers (3)

DaBookshah
DaBookshah

Reputation: 196

Visual Studio works just fine with Rcpp. Has done for years. I disagree with Dirk Eddelbuettel.

This is an important fact - For example, there are very important libraries (Intels MKL, QT graphics framework) which are actually not compatible with minGW.

I maintain a (patched and cut-down) fork of Rcpp on github (https://github.com/rohan-shah/Rcpp) suitable for compilation with Visual Studio with cmake. The patch is something like five lines, I believe.

Disclaimer: It's fiddly to use, and you have to know what you're doing. If you do know what you're doing though, I've done quite a bit of the work for you. See https://github.com/rohan-shah/mpMap2 for an example of how to use patched Rcpp with Visual Studio.

Upvotes: 2

Dirk is no longer here
Dirk is no longer here

Reputation: 368201

We address this very question clearly in the Rcpp FAQ (which comes as vignette in the package, is on the CRAN site and its mirrors, and on my website).

In short, Rcpp supports the exact same toolchain which R supports. And on Windows that is MinGW (the port of gcc to Windows) provided by the Rtools package for R.

R Core only support MinGW, and we do the same. If one could compile R with Visual Studio, things would be easier, but as Rcpp sits on top of R we are playing the hand we are dealt with.

So sorry, the answer is a "No" to Visual Studio.

Upvotes: 6

Henrik
Henrik

Reputation: 14450

The question is what you really want to connnect with what. If you want to use R within C++ Rcpp seems to be the wrong decision as it connects C++ to R (and not the other way round as your question implies.).

If you want to connect R to C++ and use Visual C++ for creating your C++ code only (instead of linking R to C++), you might want to check this recent blog post (found via R-bloggers.com). It tells you a possible way of doing so.

Upvotes: 2

Related Questions