RSTAN on Windows

Hey everyone,
I am trying to build a Test package which uses RStan. The package only consits of one function. But somehow the package does not build do to the following Error:

  • installing to library ‘C:/Program Files/R/R-3.6.1/library’
  • installing source package ‘rstanlm’ …
    ** using staged installation
    ** libs
    Error in .shlib_internal(args) :
    C++14 standard requested but CXX14 is not defined
  • removing ‘C:/Program Files/R/R-3.6.1/library/rstanlm’
  • restoring previous ‘C:/Program Files/R/R-3.6.1/library/rstanlm’

Exited with status 1.

The R file consits of the following:
lm_stan ← function(x, y, …) {
standata ← list(x = x, y = y, N = length(y))
out ← rstan::sampling(stanmodels$lm, data = standata, …)
The Stan file:
// Save this file as inst/stan/lm.stan
data {
int<lower=1> N;
vector[N] x;
vector[N] y;
parameters {
real intercept;
real beta;
real<lower=0> sigma;
model {
// … priors, etc.

y ~ normal(intercept + beta * x, sigma);

In the following thread this issue was discussed but no option did work out. I thought maybe if I have a updated win-build Rstan URL it might work but I dont know where to find one. And I am also not sure if this will solve the issue.

When building R packages that use rstan, make sure you use the rstantools package: GitHub - stan-dev/rstantools: Tools for Developing R Packages Interfacing with Stan