[Rd] RStudio Calling C++ Visual Studio DLL

Dirk Eddelbuettel edd at debian.org
Sat Feb 21 18:44:05 CET 2015


On 21 February 2015 at 10:45, Alex Restrepo wrote:
| I'm a newbie to R and I am interested
| in seeing a simple example of calling a 3rd party Visual Studio generated DLL
| from RStudio. Does anyone have a simple example which also walks through the
| preliminary steps of setting up the INCLUDE path and the library path to either
| a DLL or LIB file ? I have tried to find an easy example, but thus far had no
| luck finding an example using Rcpp to communicate to a 3rd party visual studio
| DLL. 

Please see "Question 2.9: Can I use Rcpp with Visual Studio" in the Rcpp FAQ
(eg at http://cran.rstudio.com/web/packages/Rcpp/vignettes/Rcpp-FAQ.pdf)
which we wrote about four years ago, but which still stands:

As a courtesy, the text of that Q and A is:

  \subsection{Can I use \pkg{Rcpp} with Visual Studio ?}

  Not a chance.

  And that is not because we are meanies but because \proglang{R} and Visual
  Studio simply do not get along. As \pkg{Rcpp} is all about extending
  \proglang{R} with \proglang{C++} interfaces, we are bound by the available
  toolchain.  And \proglang{R} simply does not compile with Visual Studio. Go
  complain to its vendor if you are still upset.

If you have expert-level understanding of C++ and Visual Studio, you can make
this work.  Yet it will still remain unsupported for as long R itself does
not support Visual Studio / Visual C++.  A potentially more reliably but
still rather painful process would be to write a C-language wrapper to every
function you want to need, and then call that.  Cross-compiler linking works
for C, it does not for C++ due to unstandardized name wrangling.

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org



More information about the R-devel mailing list