[Rcpp-devel] Rcpp C++11 on Windows

Martyn Plummer plummerm at iarc.fr
Wed Jan 27 12:13:25 CET 2016


On Wed, 2016-01-27 at 11:35 +0100, Peter Meissner wrote:
> Hey Listeners,
> 
> I am quite solid in R but a complete noob to C++ and Rcpp so please excuse  
> if do not get it right ...
> 
> My problem is that I would like to have a package using Rcpp AND using  
> C++11 features AND working on both Linux (Debian derivates) and Windows.  
> For Linux I seem to be on the right track and features like 'auto' and  
> 'iterators' do work. On Windows however it will not compile.
> 
> As far as I understand it, the main problem is that Rtools comes with a  
> compiler that simply does not support those features (g++ version 4.6.3).  
> Furthermore, I found that C++11 features are not CRAN compatible - right?

OK There are two issues here

Q1: Does CRAN accept C++11 code?
A1: Yes but you have to indicate that you are using C++11 rather than C
++98, which is still the default standard for CRAN packages. This is
described in the "Writing R Extensions" manual in section 1.2.4.

Q2: Are C++11 features available on Windows?
A2: Not yet. Release 4.6.3 includes limited support for C++11 features.
Again, the "Writing R Extensions" manual will give you more details,
with a link to a page describing what features are available. There are
plans to update the toolchain on Windows to 4.9.2. This will improve C
++11 support on windows but it will not be complete. The first
fully-compliant gcc release is 5.1. However, it is not sufficiently
stable on Windows.

Martyn

> Do I get it right so far? Can you give guidance on how best to proceed?  
> Should I get a newer g++/or-other compiler and make it the system default?  
> What are best or good working practices? Windows/Linux is a must and  
> system tweaks for other Windows users installing/building the package  
> should be minimal, though CRAN compliance would be only a minor extra.


> I hope I did not miss some obvious documentation or already existing  
> I-take-you-by-the-hand-blog-post.
> 
> 
> Best, Peter
> 
> 
> 
> 
> Compilation error:
> 
>    * installing to library 'C:/Users/Admin/Documents/R/win-library/3.2'
>    * installing *source* package 'spanmatcher' ...
>    g++ -m64 -std=c++0x -I"C:/PROGRA~1/R/R-32~1.3/include" -DNDEBUG     
> -I"C:/Users/Admin/Documents/R/win-library/3.2/Rcpp/include"  
> -I"d:/RCompile/r-compiling/local/local323/include"     -O2 -Wall   
> -mtune=core2 -c span_matcher_worker.cpp -o span_matcher_worker.o
>    ** libs
>    g++ -m64 -shared -s -static-libgcc -o spanmatcher.dll tmp.def  
> RcppExports.o span_matcher_worker.o  
> -Ld:/RCompile/r-compiling/local/local323/lib/x64  
> -Ld:/RCompile/r-compiling/local/local323/lib  
> -LC:/PROGRA~1/R/R-32~1.3/bin/x64 -lR
>    collect2: ld returned 148 exit status
>    no DLL was created
>    ERROR: compilation failed for package 'spanmatcher'
> 
> 
> My system:
> 
>    R version 3.2.3 (2015-12-10)
>    Platform: x86_64-w64-mingw32/x64 (64-bit)
>    Running under: Windows >= 8 x64 (build 9200)
> 
>    locale:
>    [1] LC_COLLATE=German_Germany.1252  LC_CTYPE=German_Germany.1252
>    [3] LC_MONETARY=German_Germany.1252 LC_NUMERIC=C
>    [5] LC_TIME=German_Germany.1252
> 
>    attached base packages:
>    [1] stats     graphics  grDevices utils     datasets  methods   base
> 
>    other attached packages:
>    [1] devtools_1.9.1 Rcpp_0.12.2
> 
>    loaded via a namespace (and not attached):
>    [1] tools_3.2.3
> 
> 

-----------------------------------------------------------------------
This message and its attachments are strictly confidential. If you are
not the intended recipient of this message, please immediately notify 
the sender and delete it. Since its integrity cannot be guaranteed, 
its content cannot involve the sender's responsibility. Any misuse, 
any disclosure or publication of its content, either whole or partial, 
is prohibited, exception made of formally approved use
-----------------------------------------------------------------------


More information about the Rcpp-devel mailing list