Cmdstan Installation

I am having installation problems with cmdstan on my windows 10 computer following https://mc-stan.org/docs/2_24/cmdstan-guide/cmdstan-installation.html. I’ve tried heaps of different versions of cmdstan (including cloning the latest version from github, 2.17.1, 2.17.0, 2.23.0) and rtools 40 and 35. I’ve gotten the message

— CmdStan v[2.23.0] built —

for the different versions I’ve tried. But when I try the bernoulli example it fails and says “make: *** No rule to make target ‘examples/bernoulli/bernoulli’. Stop.” Another message that I’ve gotten is “collect2.exe: error: ld returned 1 exit status
make: *** [make/command:4: bin/stanc.exe] Error 1”

a few questions:

this is just about CmdStan, right? where does matlab fit into this?

possible problem is that if you’re cloning from GitHub, then makefile is going to try to download stanc compiler pre-built binary, and Windows 10 seems to have security settings that block the downloads - that would explain why you can’t compile the example model.

if you start with the latest release from this URL: https://github.com/stan-dev/cmdstan/releases/tag/v2.24.1
tarball is: https://github.com/stan-dev/cmdstan/releases/download/v2.24.1/cmdstan-2.24.1.tar.gz

this tarball has the pre-built binary for the stanc compiler - all you need to do is download, unpack, and from the base directory cmdstan-2.24.1 run make build
to test, from same directory, follow up with make examples/bernoulli/bernoulli

hope this helps!

I will be using Matlab but yes this is a cmdstan issue. I will correct that.

Thanks for your help but I still get the same error:

C:\Users\AF\Desktop\Apps\cmdstan-2.24.1>make examples/bernoulli/bernoulli
make: *** No rule to make target ‘examples/bernoulli/bernoulli’. Stop.

I also tried: mingw32-make examples/bernoulli/bernoulli (as well as replacing it with \) and that didn’t work either.

try this:

make examples/bernoulli/bernoulli.exe

cf: https://mc-stan.org/docs/2_24/cmdstan-guide/compiling-a-stan-program.html

On Windows, the command is the same with the addition of .exe at the end of the target (note the use of forward slashes):

Thanks this worked but now I have another error when I use matlabstan:

Having a problem getting stan version.
This is likely a problem with Java running out of file descriptors
Trying again.
Trying again.
Trying again.
Trying again.
Trying again.
Trying again.
Giving up.
Error using cellfun
Non-scalar in Uniform output, at index 1,
output 1.
Set ‘UniformOutput’ to false.

Error in StanModel/stan_version (line 850)
ver =
cellfun(@str2num,regexp(str{3},’.’,‘split’));

Error in StanModel (line 196)
ver = self.stan_version();

Error in stan (line 108)
model = StanModel();

Error in Untitled (line 27)
fit =
stan(‘model_code’,schools_code,‘data’,schools_dat);

Would you have any idea how to solve this? I’ve had a look at past posts about this but there doesn’t seem to be a solution (those posts seemed pretty old so hopefully there is a solution now)…

not a matlab person - @brian-lau ?