I have successfully downloaded the R package cmdstanr. I am facing this error to compile the stan file.
I have tried updating R and renaming the stan file nothing helps. Please help me out.
cauchy.mod ← cmdstan_model(cauchy.code)
Compiling Stan program…
In file included from stan/lib/stan_math/stan/math/prim/prob/von_mises_lccdf.hpp:5,
from stan/lib/stan_math/stan/math/prim/prob/von_mises_ccdf_log.hpp:4,
from stan/lib/stan_math/stan/math/prim/prob.hpp:359,
from stan/lib/stan_math/stan/math/prim.hpp:16,
from stan/lib/stan_math/stan/math/rev.hpp:16,
from stan/lib/stan_math/stan/math.hpp:19,
from stan/src/stan/model/model_header.hpp:4,
from C:/Users/a0bha/AppData/Local/Temp/Rtmp6BK5Ex/model-41cc503755aa.hpp:2:
stan/lib/stan_math/stan/math/prim/prob/von_mises_cdf.hpp: In function ‘stan::return_type_t<T_x, T_sigma, T_l> stan::math::von_mises_cdf(const T_x&, const T_mu&, const T_k&)’:
stan/lib/stan_math/stan/math/prim/prob/von_mises_cdf.hpp:194: note: ‘-Wmisleading-indentation’ is disabled from this point onwards, since column-tracking was disabled due to the size of the code/headers
194 | if (cdf_n < 0.0)
|
stan/lib/stan_math/stan/math/prim/prob/von_mises_cdf.hpp:194: note: adding ‘-flarge-source-files’ will allow for more column-tracking support, at the expense of compilation time and memory
C:/rtools42/ucrt64/bin/…/lib/gcc/x86_64-w64-mingw32/13.2.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe
: src/cmdstan/main.o:main.cpp:(.text+0x96b4): undefined reference to std::istream::seekg(std::fpos<int>)' C:/rtools42/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: src/cmdstan/main.o:main.cpp:(.text+0xda03): undefined reference to std::istream::seekg(std::fpos)’
C:/rtools42/ucrt64/bin/…/lib/gcc/x86_64-w64-mingw32/13.2.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe
:
src/cmdstan/main.o:main.cpp:(.text$_ZN4stan2io15stan_csv_reader12read_samplesERSiRN5Eigen6MatrixIdLin1ELin1ELi0ELin1ELin1EEERNS0_15stan_csv_timingEPSo[_ZN4stan2io15stan_csv_reader12read_samplesERSiRN5Eigen6MatrixIdLin1ELin1ELi0ELin1ELin1EEERNS0_15stan_csv_timingEPSo]+0x75d): undefined reference to `std::istream::seekg(std::fpos)’
Yeah it is with all the models.
Some models have this error, however there is no missing ; in the code.
Compiling Stan program…
Syntax error in ‘C:/Users/a0bha/AppData/Local/Temp/Rtmp6BK5Ex/model-41cc55fb2605.stan’, line 4, column 7 to column 8, parsing error:
2: int<lower=0> n;
3: real<lower=0> alpha;
4: int x[n];
^
5: int y[n];
6: }
Error: An error occured during compilation! See the message above for more information.
In addition: Warning message:
In readLines(stan_file) :
incomplete final line found on ‘S:/JD Research/twosampleDPM-main/twosample-cauchy-2.stan’
Good that you added how to solve it, I was about to add that
@Bob_Carpenter is it possible for Stan to recognize older syntax usage and give a more informative error that this syntax is outdated and a link to the documentation oof the new syntax? To avoid repeated questions and confusion about this error
Compiling Stan program…
In file included from stan/lib/stan_math/stan/math/prim/prob/von_mises_lccdf.hpp:5,
from stan/lib/stan_math/stan/math/prim/prob/von_mises_ccdf_log.hpp:4,
from stan/lib/stan_math/stan/math/prim/prob.hpp:359,
from stan/lib/stan_math/stan/math/prim.hpp:16,
from stan/lib/stan_math/stan/math/rev.hpp:16,
from stan/lib/stan_math/stan/math.hpp:19,
from stan/src/stan/model/model_header.hpp:4,
from C:/Users/a0bha/AppData/Local/Temp/RtmpCEgDbu/model-67e062143e88.hpp:2:
stan/lib/stan_math/stan/math/prim/prob/von_mises_cdf.hpp: In function ‘stan::return_type_t<T_x, T_sigma, T_l> stan::math::von_mises_cdf(const T_x&, const T_mu&, const T_k&)’:
stan/lib/stan_math/stan/math/prim/prob/von_mises_cdf.hpp:194: note: ‘-Wmisleading-indentation’ is disabled from this point onwards, since column-tracking was disabled due to the size of the code/headers
194 | if (cdf_n < 0.0)
|
stan/lib/stan_math/stan/math/prim/prob/von_mises_cdf.hpp:194: note: adding ‘-flarge-source-files’ will allow for more column-tracking support, at the expense of compilation time and memory
C:/rtools42/ucrt64/bin/…/lib/gcc/x86_64-w64-mingw32/13.2.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe
:
src/cmdstan/main.o:main.cpp:(.text+0x96b4): undefined reference to std::istream::seekg(std::fpos<int>)' C:/rtools42/ucrt64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: src/cmdstan/main.o:main.cpp:(.text+0xda03): undefined reference to std::istream::seekg(std::fpos)’
C:/rtools42/ucrt64/bin/…/lib/gcc/x86_64-w64-mingw32/13.2.0/…/…/…/…/x86_64-w64-mingw32/bin/ld.exe
: src/cmdstan/main.o:main.cpp:(.text$_ZN4stan2io15stan_csv_reader12read_samplesERSiRN5Eigen6MatrixIdLin1ELin1ELi0ELin1ELin1EEERNS0_15stan_csv_timingEPSo[_ZN4stan2io15stan_csv_reader12read_samplesERSiRN5Eigen6MatrixIdLin1ELin1ELi0ELin1ELin1EEERNS0_15stan_csv_timingEPSo]+0x75d): undefined reference to `std::istream::seekg(std::fpos)’
Error: An error occured during compilation! See the message above for more information.
In addition: Warning message:
In readLines(stan_file) :
incomplete final line found on ‘S:/JD Research/twosampleDPM-main/twosample-cauchy-2.stan’
it looks like it may be an issue with RTools. It looks like that’s bringing in a very recent GCC 13.2.
I don’t know where you’re at in installs, but it’s easy to get these things in a bad enough state that it’s easier just to start from scratch by reinstalling R and reinstalling cmdstan and cmdstanr. If you could do that and follow along the instructions step by step and see where things break. The install instructions are here:
but that’s confusing in that it doesn’t tell you how to do the full install. The next bigger set of partial instructions are here:
This then redirects you to install a C++ toolchain for CmdStan here, which after scrolling down to the right section leaves you here:
You’ll see that each of the R tools releases needs slightly different steps.
And if you’re trying to run on a really old 32-bit Windows machine then there is an additional step at the end.
P.S. If you’re comfortable with the Unix subsystem for Windows, that tends to be much easier to work with than Windows itself for Stan (and many other open source software package). Windows is just different enough from Unix that everything works differently there and zero of our 40+ devs have Windows machines (primarily because they’re such a pain for scientific computing).
Oh, and I should have said you should get C++ tools installed and make sure they work before trying to go onto the next step. You should be able to open a terminal and do this:
$ gcc --version
and get an answer. This will check that the right version is on your PATH.