[Rcpp-devel] Rcmd build in Windows
Dahir Alihassan
da288 at cantab.net
Wed Mar 23 12:38:16 CET 2011
Hi,
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.
Dahir.
On Tue, March 22, 2011 15:10, Dominick Samperi wrote:
> Hello,
>
>
> Rcpp is designed to facilitate command-line builds and builds of
> contributed packages at CRAN (to encourage contributions). Custom builds
> using stand-alone IDE's will, of course, have to be configured manually,
> and Makevars.win will not help much unless it is rewritten.
>
> Thanks for the pointer to CodeBlocks. I hadn't tried this. It
> appears that it only supports VC++ 6, not VC++ 2010, etc.
>
> Have you tried to VC++ support? Does it include support
> for 64bit builds? Have you built packages using VC++, or just using GCC?
>
> Have you tried building R using this tool, or just package DLL's that
> link to the pre-built R?
>
> Thanks,
> Dominick
>
>
> On Tue, Mar 22, 2011 at 6:32 AM, Dahir Alihassan <da288 at cantab.net>
> wrote:
>
>> Hi,
>>
>>
>> I am trying to build and install (Rcmd build) an RCPP package, with
>> RTools
>> etc installed. Initially I setup the project in an IDE (CodeBlocks) and
>> managed to link against rcpp thus producing a DLL file just fine.
>> Following this I had a look at the Writing R Extensions Manual
>> (http://cran.r-project.org/doc/manuals/R-exts.pdf) and so I am aware of
>> makevars.win and configure.win files. I also managed to install Rcpp
>> using Rcmd so clearly the toolchain is setup correctly, and thus I have
>> setup a skeleton Rcpp project for which Rcmd build and install work
>> fine.
>>
>> What I don't understand - in my case, with a prebuilt DLL - is why Rcmd
>> build needs to call g++ to recreate another DLL; it seems like I am
>> repeating the whole process I went through in the IDE. The main issue
>> is that my project links to external libraries (like C++ Boost) and so
>> Rcmd
>> build/install complains about the project include headers and paths; I
>> assume the only way to set this up is in the configure.win and
>> makevars.win files which seems fairly tedious - am I repeating the
>> whole process? I hope I am just misunderstanding the build process; I
>> have tried reading the manuals but I was hoping you could clear my head
>> with regards to this issue. Thanks very much.
>>
>> _______________________________________________
>> Rcpp-devel mailing list
>> Rcpp-devel at lists.r-forge.r-project.org
>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>>
>>
>
More information about the Rcpp-devel
mailing list