[Rcpp-devel] Rcmd build in Windows

Dirk Eddelbuettel edd at debian.org
Wed Mar 23 14:16:26 CET 2011


Dahir,

On 23 March 2011 at 11:38, Dahir Alihassan wrote:
| The solution is again not too complicated but its more about knowing
| what's going on, which isn't helped by Rcmd's cryptic error feedback
| ("Error: compilation failed."). The process is 2 stages, first getting a
| DLL compiled in your build system of choice. I managed to compile a DLL
| linking to the compiled RCPP binaries on CRAN under CodeBlocks - Visual
| Studio is a no go. The main step is to ensure you are linking to R.dll and
| libRcpp.a and you have the MinGW toolchain setup for both 32 and 64 bit
| versions linking to the respective libraries. (Otherwise you get Rcmd
| complaining about arch=x64 later on; do not try to put in 32 bit DLLs as
| placeholders under an x64 folder, it doesn't work).
| 
| Structure the package as per the RCPP skeleton (see documentation) and put
| the DLL and any other dependencies under inst/libs/i386 and x64. Ensure
| there's no C++ src folder in the R package skeleton - this is the key bit,
| you don't need the c++ files again. Then compile under command line with
| Rcmd build --binary <packagename> as standard. If you get a "is not valid
| WIN32 application" error, you need to ensure you have a 64 bit DLL (which
| is produced by linking to the 64 bit libRcpp and using the Mingw64
| toolchain). This should produce a .tar file first and then a .zip file -
| ignore any Cygwin DOS style path warnings.
| 
| I really hope that helps someone because it was pretty tedious and
| frustrating. Definitely read the documentation but it is mainly tailored
| for simple packages and not too great for Windows.

I am sorry that you are frustrated but please allow me to clarify one thing
here.  The documentation (for Rcpp) is tailored for the supported use case
for R, on Windows and elsewhere. And that is to build using the 'R CMD ...'
set of commands using the supported set of compilers (ie MinGW on Windows) by
setting CXX, PKG_CXXFLAGS, ... et al correctly. 

That process works and is the one our packages are tested against (by CRAN,
including the win-builder.r-project.org service and the CRAN checks for
windows).  And it works with the inline package if you want to quickly test
from R.

Everybody is of course free to use other tools, and but you cannot blame us
for not documenting them---we don't use them, and in many cases don't even
have them. We documented the one main use case (see above) which itself is
provided and documented by R Core.

I'd invite you to post a detailed howto somewhere (just register a blogger or
wordpress site if you have no website to use) or even send it here or maybe
start a page on the R Wiki.  But going on about how we make your life with
Code::Blocks harder doesn't help. There are lots of IDEs, and the process
will differ for all of them.  

R is cross-platform, and so is Rcpp. We have no interest in corner solutions
not supported by CRAN. If you have patches to the documentation which are of
general interest, please send them here or to Romain and myself.

Finally, good to hear that you have it all working now. I hope you find Rcpp
et al useful in your work.

Dirk

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


More information about the Rcpp-devel mailing list