Hi,
I have been developing a package that depends on RStan for a while now, the package incorporates stan models the same way as rstanarm (https://mc-stan.org/rstantools/articles/minimal-rstan-package.html). Everything was working fine until recently when StanHeaders update 2.18.1-10 came out, with this update I am no longer able to compile the package on Windows and Linux (I am able to compile it on mac though). If I revert StanHeaders back to 2.18.1 I am able to compile everything again. I also checked if this is an issue with my package but it seems like it is not, if I download rstanarm from GitHub and try to compile it locally the issues are the same (I can compile rstanarm with StanHeaders 2.18.1 but not with 2.18.2-10).
The main problem with this is that CRAN auto checks use the latest version of StanHeaders (2.18.2-10) when test compiling, so when I try to upload my package to CRAN it gets rejected beacuse of this issue with StanHeaders .
Thanks!
This is most likely due to the lack of specifying the C++14 stuff in your src/Makevars and src/Makevars.win files. Do you have a link to the package repository?
This is the link: https://github.com/bstatcomp/bayes4psy.
Below is the content of Makevars and Makevars.win, thanks!
Makevars
STANHEADERS_SRC = `"$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" --vanilla -e "cat(system.file('include', 'src', package = 'StanHeaders'))"`
PKG_CPPFLAGS = -I"../inst/include" -I"$(STANHEADERS_SRC)" -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -DBOOST_MATH_OVERFLOW_ERROR_POLICY=errno_on_error
SOURCES = $(wildcard stan_files/*.stan)
OBJECTS = $(SOURCES:.stan=.o) init.o
all: $(SHLIB)
@if test -e "/usr/bin/install_name_tool" && test -e "/usr/local/clang4/lib/libc++.1.dylib" && test -e "/usr/lib/libc++.1.dylib"; then /usr/bin/install_name_tool -change /usr/local/clang4/lib/libc++.1.dylib /usr/lib/libc++.1.dylib $(SHLIB); fi
clean:
rm -rf stan_files/*.o
rm -rf *.so *.o
rm -rf stan_files/*.cc
rm -rf stan_files/*.hpp
%.cc: %.stan
"$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "source(file.path('..', 'tools', 'make_cc.R')); make_cc(commandArgs(TRUE))" $<
.phony: all clean
Makevars.win
STANHEADERS_SRC = `"$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" --vanilla -e "cat(system.file('include', 'src', package = 'StanHeaders'))"`
BOOST_NOT_IN_BH_SRC = `"$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" --vanilla -e "cat(system.file('include', 'boost_not_in_BH', package = 'rstan'))"`
PKG_CPPFLAGS = -I"../inst/include" -I"$(STANHEADERS_SRC)" -I"$(BOOST_NOT_IN_BH_SRC)" -DBOOST_RESULT_OF_USE_TR1 -DBOOST_NO_DECLTYPE -DBOOST_DISABLE_ASSERTS -DEIGEN_NO_DEBUG -DBOOST_NO_CXX11_RVALUE_REFERENCES
CXX_STD = CXX11
SOURCES = $(wildcard stan_files/*.stan)
OBJECTS = $(SOURCES:.stan=.o) init.o
all: $(SHLIB)
clean:
RM -rf stan_files/*.o
RM -rf *.so *.o
RM -rf stan_files/*.cc
RM -rf stan_files/*.hpp
%.cc: %.stan
"$(R_HOME)/bin$(R_ARCH_BIN)/Rscript" -e "source(file.path('..', 'tools', 'make_cc.R')); make_cc(commandArgs(TRUE))" $<
.phony: clean
Yes, in both files you need CXX_STD = CXX14 and ideally also
CXX14STD = -std=c++1y`.
2 Likes
This solved my problems, thanks!