Windows 11 cmdstan installation issue: Architecture not detected, related to version_tbb_2020.3

I have been searching all available information on these forums, GitHub Issues, and Stackoverflow, and trying out various solutions, all without success, to install CmdStan on a Windows 11 machine, on which I do not have admin rights (though I can consult an admin when needed to install software).

I have done the following:

  • Download CmdStan source code into C:/Users/(myname)/Documents/.cmdstan/cmdstan-2.34.1
  • Run Rtools43 bash and use pacman to make sure the compilers are installed properly (or so I think)
  • Attempt to install CmdStan in two different ways
    • Tried it from within R cmdstanr::install_cmdstan() , after ensuring that all Rtools and that kind of thing are present in the PATH variable.
    • Opened the Rtools43 bash shell, added /c/rtools43/mingw64/bin to the PATH variable to make sure that mingw32-make and g++ are available, then navigate to the directory where CmdStan source code is and run mingw32-make build

Regardless of which of these I try, I ultimately run into the following error message, which appears after a long string of output when running install_cmdstan() in R, and appears immediately without any preceding output when running mingw32-make build from the Rtools43 bash shell:

touch stan/lib/stan_math/lib/tbb/version_tbb_2020.3
tbb_root="../tbb_2020.3" CXX="g++" CC="gcc" LDFLAGS='-Wl,-L,"C:/Users/Quentin.Read/Documents/.cmdstan/cmdstan-2.34.1/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"C:/Users/Quentin.Read/Documents/.cmdstan/cmdstan-2.34.1/stan/lib/stan_math/lib/tbb"  ' 'C:/rtools43/mingw64/bin/mingw32-make.exe' -C "stan/lib/stan_math/lib/tbb" -r -f "C:/Users/Quentin.Read/Documents/.cmdstan/cmdstan-2.34.1/stan/lib/stan_math/lib/tbb_2020.3/build/Makefile.tbb" compiler=gcc cfg=release stdver=c++1y  CXXFLAGS="-D_UCRT"
mingw32-make[1]: Entering directory 'C:/Users/Quentin.Read/Documents/.cmdstan/cmdstan-2.34.1/stan/lib/stan_math/lib/tbb'
process_begin: CreateProcess(C:\Windows\System32\cmd.exe, cmd /C "cscript /nologo /E:jscript ../tbb_2020.3/build/detect.js  /arch gcc", ...) failed.
../tbb_2020.3/build/ pipe: No error
process_begin: CreateProcess(C:\Windows\System32\cmd.exe, cmd /C "cscript /nologo /E:jscript ../tbb_2020.3/build/detect.js  /runtime gcc", ...) failed.
../tbb_2020.3/build/ pipe: No error
../tbb_2020.3/build/ *** Architecture not detected.  Stop.
mingw32-make[1]: Leaving directory 'C:/Users/Quentin.Read/Documents/.cmdstan/cmdstan-2.34.1/stan/lib/stan_math/lib/tbb'
mingw32-make: *** [stan/lib/stan_math/make/libraries:175: stan/lib/stan_math/lib/tbb/tbb.def] Error 2

Based on the above I have tried to find information about TBB and how this error can be resolved but I have not been successful. None of the (many many many) forum posts, questions, and threads related to installing CmdStan on Windows address this exact issue, and none of the tricks suggested by users and developers on any of the threads have worked for my situation.

I am at my wits’ end and have been trying to fix this for a long time now. It is very important for me to be able to fix this because I will soon be forced to switch to the Windows 11 operating system by my employer. I was provided with a tester machine to test out installations on, before I have to give up my current machine and have it reimaged with the new OS. I would love to be able to get CmdStan running on this tester machine, so that I can be confident it will work for me moving forward. Thanks for your help!

See for example some of the posts that promise to be helpful but haven’t enabled me to overcome the TBB architecture not detected error message. All of these reference TBB somehow.

do you have Python on your system? you could try a conda install.
(also Cmdstanpy ::


1 Like

Thanks for the suggestion. I will get the admin to install conda on my system and report back.

The conda install was successful! I am able to compile and sample models with brms and cmdstanr backend, on the Windows 11 machine. @mitzimorris thanks so much! I would still be interested in whether there is a solution to this problem that does not involve conda install, and I think it would be of general interest to Windows 11 users.

1 Like

I do not know if this will be relevant but I installed this in Windows 10 and also had some issues initially. I used cmdstanpy (python wrapper for cmdstan) but the installations steps for cmdstan remains the same:

  1. Clone the github repo for cmdstan
  2. Install a valid toolchain. I used Rtools40 for this. And installed the gcc toolchain using pacman -Sy mingw-w64-ucrt-x86_64-make which installs the toolchain under the folder C:\rtools40\ucrt64\bin which needs to be added to the path. This should also work for different versions of Rtools.
  3. Navigate to the cloned repo of cmdstan, denoted by <cmdstan home> and run the mingw32-make build utility.
  4. Add the tbb library <cmdstan home>\stan\lib\stan_math\lib\tbb to the path

You can try these steps too see if it will work for you. You probably need to then configure the <cmdstan home> variable in r as well (I am not familiarly with r at all, but I assume this is probably the same as the python wrapper).

1 Like

Glad the conda distribution worked for you. We recently had some changes (still unreleased) to the specific part of the build that was failing for you:

@andrjohns may be able to weigh in, or possibly his changes will have fixed this

1 Like

Wow that pull request looks very promising! I will test it out when it is released.

@Garren_Hermanus I believe I tried to do more or less exactly what you did but perhaps I did not add the correct TBB library path to the path variable. I will try it again. Thanks for your help!

I wanted to update that as of today, I was able to successfully install cmdstan through cmdstanr::install_cmdstan(), so it looks like the changes that were made in PR 2999 possibly helped with that? Anyway I am really thankful for all of your hard work!