mercredi 26 avril 2017

Rcpp plugin for C++11 not working since update to R 3.4.0

Since I updated R to the new version 3.4.0, the Rcpp plugin to enable C++11 does not seem to work properly. (Note that this is a different situation as reported here http://ift.tt/2oMeYuJ)

I have C++ files requiring C++11 standard that I compile in R via Rcpp using the command Rcpp::sourceCpp(foo.cpp). The R default standard is C++98 but I could change that by adding the following command in my C++ file
// [[Rcpp::plugins("cpp11")]]

This does not work anymore with the new version of R 3.4.0, my compiler use the default standard (C++98) instead of C++11, despite the plugin. It used to work with previous version of R.

My solution for the moment is to set an environment variable for my R session: Sys.setenv("PKG_CXXFLAGS"="-std=c++11")

Here is the configuration I use in R:

sessionInfo()
R version 3.4.0 (2017-04-21) Platform: x86_64-suse-linux-gnu (64-bit) Running under: openSUSE Leap 42.2
Matrix products: default BLAS: /usr/lib64/R/lib/libRblas.so LAPACK: /usr/lib64/R/lib/libRlapack.so locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages: [1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached): [1] compiler_3.4.0 rsconnect_0.4.3 tools_3.4.0

I use the Rcpp package version 0.12.1.0. My compiler is the following:

~$ g++ --version | head -n1
g++ (SUSE Linux) 4.8.5 

Am I missing something? Has anyone else encountered the same issue?

Aucun commentaire:

Enregistrer un commentaire