Package building with rstantools 2.0.0

Yes, that is the problem. But it is not supposed to be happening if you can compile other things with g++. Like for example, can you do R CMD build package_dir where package_dir is the directory where your package is.

asael, I wasnā€™t suggesting to use the files from ctsem, the readme on github (first page, below the files) describes various steps to take. I expect you need rtools in your path, like so:

In case of compile errors like g++ not found , ensure the devtools package is installed:

install.packages('devtools')

and include the following in your .Rprofile

library(devtools) 

Sys.setenv(PATH = paste("C:/Rtools/bin", Sys.getenv("PATH"), sep=";")) 

Sys.setenv(PATH = paste("C:\\Rtools\\mingw_64\\bin", Sys.getenv("PATH"), sep=";")) 

Sys.setenv(BINPREF = "C:/Rtools/mingw_$(WIN)/bin/")
3 Likes

@Charles_DriverThank you so much that actually works! Thanks, @bgoodri and @jonah for all the patience and help! Yeiiiiiiiiiii!!!

1 Like

@Charles_Driver Thanks for helping out. Is this something that most people using Windows/rtools are going to encounter when using rstantools to develop a package (I am no Windows expert)? If so we should either include your solution somewhere in our docs or figure out a way to avoid it being necessary for the user to figure that out.

@jonah, itā€™s definitely a problem when people install from github, and I donā€™t think itā€™s at all specific to ctsem. Only a few ctsem users are making use of the models that require compilation (nonlinear sde) so far as Iā€™m aware, so Iā€™m still not certain whether it is an issue when installing from CRAN but I assume so. I only recently realised it was such a widespread problem, definitely need to find a better way to deal with itā€¦

Ok. I just spent a bit of time fixing up an install script that is hopefully fairly robust, found here: https://github.com/cdriveraus/ctsem/raw/master/installctsem.R
I tried out various incarnations (removed rtools, rstan, makevars, no rtools in path) but couldnā€™t reproduce the g++ not found error, though had it a lot at a workshop I taught recently.

1 Like