dvats / mcmcse

Markov chain Monte Carlo Standard Errors
Other
12 stars 3 forks source link

Missing declaration of C++11 compiler support #2

Closed ngmarchant closed 3 years ago

ngmarchant commented 3 years ago

Thanks for your work on this package Dootika.

I'm trying to install the latest release from CRAN on an Ubuntu 16.04 system with R 3.4.4, but I'm getting an error. A snippet of the output is included below

* installing *source* package ‘mcmcse’ ...
** package ‘mcmcse’ successfully unpacked and MD5 sums checked
** libs
g++  -I/usr/share/R/include -DNDEBUG  -I"/data/R/x86_64-pc-linux-gnu-library/3.4/Rcpp/include" -I"/data/R/x86_64-pc-linux-gnu-library/3.4/RcppArmadillo/include"    -fpic  -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g  -c RcppExports.cpp -o RcppExports.o
In file included from /data/R/x86_64-pc-linux-gnu-library/3.4/RcppArmadillo/include/armadillo:21:0,
                 from /data/R/x86_64-pc-linux-gnu-library/3.4/RcppArmadillo/include/RcppArmadilloForward.h:49,
                 from /data/R/x86_64-pc-linux-gnu-library/3.4/RcppArmadillo/include/RcppArmadillo.h:31,
                 from RcppExports.cpp:4:
/data/nmarchant/R/x86_64-pc-linux-gnu-library/3.4/RcppArmadillo/include/armadillo_bits/compiler_check.hpp:50:4: error: #error "*** C++11 compiler required; enable C++11 mode in your compiler, or use an earlier version of Armadillo"
   #error "*** C++11 compiler required; enable C++11 mode in your compiler, or use an earlier version of Armadillo"
    ^
In file included from /usr/include/c++/5/cstdint:35:0,
                 from /data/R/x86_64-pc-linux-gnu-library/3.4/RcppArmadillo/include/armadillo:28,
                 from /data/R/x86_64-pc-linux-gnu-library/3.4/RcppArmadillo/include/RcppArmadilloForward.h:49,
                 from /data/R/x86_64-pc-linux-gnu-library/3.4/RcppArmadillo/include/RcppArmadillo.h:31,
                 from RcppExports.cpp:4:
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
<cut>

It seems R is trying to build the package using the C++98 standard (the default on some older systems). This can be fixed by declaring that a C++11 compiler is required to build your package (see Writing R Extensions guide). You would just need to add the following line to src/Makevars and src/Makevars.win:

CXX_STD = CXX11
dvats commented 3 years ago

Many thanks for pointing this out, Neil. I've now pushed the changes here. The CRAN version I hope to get to soon, but hopefully till then, this can suffice. I am closing this issue now.