Cmdstan installation on windows

Hi,

As suggested in https://github.com/stan-dev/cmdstan/wiki/Getting-Started-with-CmdStan I have cloned cmdstan using

git clone https://github.com/stan-dev/cmdstan.git --recursive

and then make build.
I am using rtools 3.5 and my path contains
c:/rtools/bin
c:/rtools/mingw_64

So far so good but after a while I got a message:
C:\Rtools\mingw_64\bin\ar.exe: creating stan/lib/stan_math/lib/sundials_4.1.0/lib/libsundials_kinsol.a
ERROR: Please use mingw32-make on Windows to build the Intel TBB library.

Is some additional configuration necessary?

Thanks for any advice.

PS. I have installed rtools3.4 and latest cmdstan tarball. Amazingly it builds.

Instead of make use mingw32-make.

4 Likes

Does this mean run this command:

mingw32-make build

instead of:

make build

?

That is correct.

Thanks but unfortunately Iā€™m getting the error:

ā€˜mingw32-makeā€™ is not recognised as an internal or external command

Iā€™ve been following the cmdstan installation instructions here (1 CmdStan Installation | CmdStan Userā€™s Guide) but notice a few differences:

  1. The directory RTools has installed to seems to be C:\RBuildTools\4.0\ and not C:\RTools\RTools40\. I have therefore adjusted the directories listed in PATH accordingly to:
  • C:\RBuildTools\4.0\mingw64\bin and

  • C:\RBuildTools\4.0\usr\bin

Is this ok?

  1. Neither of the two directories above contain a mingw32-make.exe file. Only the usr\bin directory contains a make.exe file. Also when I run command mingw32-make --version Iā€™m getting the same ā€˜not recognisedā€™ error. If I run make --version I get:

GNU Make 4.2.1
Built for x86_64-pc-msys
Copyright (C) 1988-2016 Free Software Foundation, Inc.

What else should I try in order to get the make build command to run without errors?

Yes, that is correct.

Run

pacman -Sy mingw-w64-x86_64-make

In your powershell and then restart the shell. You should have mingw32-make then.

2 Likes

That worked, thank you.

thanks to everyone on this thread - Iā€™ve opened a docs issue https://github.com/stan-dev/docs/issues/268 to track these discussions so that we can keep the docs and CmdStan wiki up-to-date.

2 Likes

Iā€™m somewhat late to the party here, but Iā€™m getting exactly this issue. The proposed solutions donā€™t satisfy me becaase:
a - they donā€™t work for me
b - Iā€™ve already installed RTools, msys, and gcc in all its bloated horror, and already have 32 and 64 bit versions of mingw make. Is the Intell tlb make looking for make.exe under a different alias? And why mingw32? Does it only build as a 32 bit library?

Also, while Iā€™m here - what is the function of the Intel TBB library in this context?

Following is bash output with the error I get:

$ make build
INFO: Could not find files for the given pattern(s).
if ! [[ make =~ mingw32 ]]; then
echo ā€œERROR: Please use mingw32-make on Windows to build the Intel TBB library.ā€;
echo ā€œThis is packaged with RTools, for example.ā€;
exit 1;
fi
ERROR: Please use mingw32-make on Windows to build the Intel TBB library.
This is packaged with RTools, for example.
make: *** [stan/lib/stan_math/make/libraries:153: stan/lib/stan_math/lib/tbb/tbb-make-check] Error 1

1 Like

You need to use mingw32-make build. TBB requires mingw32-make and that is why cmdstan also requires its use.

Its used for multithreading.

2 Likes

Hi Rok

Thanks for your answer.

But, the point of my question, for Windows users, was to ask the difference between the make.exe downloaded as part of Rtools and the mingw32-make(exe?) required to build tbb. There is a certain amount of jibber-jabber on this new internet thing about how mingw32-make.exe is obsolete. And one of make or ming32-make does the job.

But, dunno. Iā€™ve given building cmdstan on Windows my best shot. And Iā€™ve failed. So PyMCMC3.

And. if my comments on this forum have been tetchy, I apologise. But, personally - Iā€™ve made a living out of computer programming for 40+ years, and I find the process of getting cmdstan to install on my insanely powerful, by the standards of my youth, computer insanely infuriating. In my case, because I want to follow along with books by McElreath and Lambert, they say all you have to do is install STAN. Whacko, good luck with that.

1 Like

Hi, did you try installation with CmdStanPy

mingw32-make is actually 64bit make and has some extra properties that the default make probably donā€™t have.

I usually do this (in cmd.exe)

pip install cmdstanpy
python -m cmdstanpy.install_cxx_toolchain
python -m cmdstanpy.install_cmdstan --compiler

And then in Python script I do this to add compiler to the PATH

from cmdstanpy.utils import cxx_toolchain_path
cxx_toolchain_path()
2 Likes

this is valuable feedback - and I mean this most sincerely. I fear that many others have done the same, but we have no way of figuring out how many more people would use Stan if it werenā€™t for installation woes.

thanks to Ari, CmdStanPy does address the CXX toolchain problems on Windows - itā€™s worth a try, and if it doesnā€™t work, please file an issue.

2 Likes

For what itā€™s worth I had no difficulty at all building cmdstan with threading support in Windows and adapting my own R code to use cmdstanr instead of Rstan, and Iā€™m just an ordinary user and strictly recreational programmer.

Up to date and complete documentation of the installation process would be a big help. I got at least one important piece of information from a blog post by @Max_Mantei that seems to have disappeared unfortunately (the necessary hint about using pacman to install mingw32-make.exe is upthread somewhere).

Confusingly enough, mingw32-make builds for 64 bit architecture.

1 Like

this is indeed 404 - https://www.maxmantei.com/blog/2020-05-16-installing-cmdstanr-on-windows/cmdstanr-windows/#r-4-0-and-rtools-4-0

Edit by @Max_Mantei: Fixed the websiteā€¦ new link: https://www.maxmantei.com/2020/05/16/cmdstanr-windows/#r-4.0-and-rtools-4.0

Thanks for the helpful response. Iā€™ll give it ago. Apologies again for being tetchy. Note to self: do not post when in a bad mood. Stan is obviously a hugely powerful piece of software, and I regret sounding negative. Iā€™d like to get it running under Windows. I have now got it going on a Mac with no issues, so at least I can follow the books. Iā€™d still like to run under Windows as well, and will give it another crack.

2 Likes

Apologies if itā€™s bad form to update an old issue, but I would like to summarize what helped me install cmdstan for windows, in case itā€™s useful for future folks searching for the same windows installation issues. Big thanks to all on this thread, you saved me right when I was about to give up!

I was struggling for multiple days trying to install cmdstan various different ways, running into strange compiler issues left and right. I was able to eventually get it working using the Installation from GitHub instructions and help from this thread. Just to summarize for those who might feel lost, these are the steps that worked for me:

  • Install the C++ toolchain using RTools 4.0
  • Adding RTools40 bin paths to the PATH environment variable, as suggested in the C++ Toolchain instructions for windows
  • May not be relevant to you: Removing any other PATH entries that I had added earlier to other g++ or mingw32-make installations.
  • Building mingw32-make using pacman -Sy mingw-w64-x86_64-make as suggested in this thread.
  • Clone the cmdstan GitHub repo as listed in the instructions (using GitHub desktop to take care of the recursive cloning)
  • Use mingw32-make build to build the stan executables.
  • Check the Stan compiler (in the instructions) after installation.

Credits:

TLDR; if youā€™re running into C++ or g++ compiler issues, try building it all from GitHub source ā€“ itā€™s easier than I expected. I was able to get it working in ~15 minutes after giving up on other (conda) installation methods that I assumed would be fast.

3 Likes