Trouble installing CmdStan under Windows

Hello,

after multiple runs of trying to install CMDStan (via make build -j4; mingw32-make -j4) I always get the same error message: ( a shortened version of the error messages is displayed below).
Please note that I have includes Rtools mingw32 and windows/system in my PATH.

  • Operating System: Windows
  • CmdStan Version: 2-22.1
  • Compiler/Toolkit: Rtools33

Any help would be appreciated. Thank you very much!

INFORMATION: Es konnten keine Dateien mit dem angegebenen
Muster gefunden werden.
g++ -std=c++1y -m64 -D_REENTRANT -Wall -Wno-unused-function -Wno-uninitialized -Wno-unused-but-set-variable -Wno-unused-variable -Wno-sign-compare -Wno-unused-local-typedefs -I stan/lib/stan_math/lib/tbb_2019_U8/include -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.3 -I stan/lib/stan_math/lib/boost_1.72.0 -I stan/lib/stan_math/lib/sundials_4.1.0/include -D_USE_MATH_DEFINES -DBOOST_DISABLE_ASSERTS -c -MT src/cmdstan/stanc.o -M -E -MG -MP -MF src/cmdstan/stanc.d src/cmdstan/stanc.cpp
g++ -std=c++1y -m64 -D_REENTRANT -Wall -Wno-unused-function -Wno-uninitialized -Wno-unused-but-set-variable -Wno-unused-variable -Wno-sign-compare -Wno-unused-local-typedefs -I stan/lib/stan_math/lib/tbb_2019_U8/include -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.3 -I stan/lib/stan_math/lib/boost_1.72.0 -I stan/lib/stan_math/lib/sundials_4.1.0/include -D_USE_MATH_DEFINES -DBOOST_DISABLE_ASSERTS -c -MT bin/cmdstan/lang/grammars/semantic_actions_def.o -MT stan/src/stan/lang/grammars/semantic_actions_def.d -M -E -MG -MP -MF stan/src/stan/lang/grammars/semantic_actions_def.d stan/src/stan/lang/grammars/semantic_actions_def.cpp
g++ -std=c++1y -m64 -D_REENTRANT -Wall -Wno-unused-function -Wno-uninitialized -Wno-unused-but-set-variable -Wno-unused-variable -Wno-sign-compare -Wno-unused-local-typedefs -I stan/lib/stan_math/lib/tbb_2019_U8/include -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.3 -I stan/lib/stan_math/lib/boost_1.72.0 -I stan/lib/stan_math/lib/sundials_4.1.0/include -D_USE_MATH_DEFINES -DBOOST_DISABLE_ASSERTS -c -MT bin/cmdstan/lang/ast_def.o -MT stan/src/stan/lang/ast_def.d -M -E -MG -MP -MF stan/src/stan/lang/ast_def.d stan/src/stan/lang/ast_def.cpp
g++ -std=c++1y -m64 -D_REENTRANT -Wall -Wno-unused-function -Wno-uninitialized -Wno-unused-but-set-variable -Wno-unused-variable -Wno-sign-compare -Wno-unused-local-typedefs -I stan/lib/stan_math/lib/tbb_2019_U8/include -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.3 -I stan/lib/stan_math/lib/boost_1.72.0 -I stan/lib/stan_math/lib/sundials_4.1.0/include -D_USE_MATH_DEFINES -DBOOST_DISABLE_ASSERTS -c -MT bin/cmdstan/lang/grammars/whitespace_grammar_inst.o -MT stan/src/stan/lang/grammars/whitespace_grammar_inst.d -M -E -MG -MP -MF stan/src/stan/lang/grammars/whitespace_grammar_inst.d stan/src/stan/lang/grammars/whitespace_grammar_inst.cpp
: fatal error: opening dependency file stan/src/stan/lang/ast_def.d: Permission denied

I don’t recognize this error, but are you using git to get a copy of cmdstan?

If so, when you clone cmdstan, do you use the ‘–recursive’ option in git?

Like:

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

?

  • Compiler/Toolkit: Rtools33

Is this a typo or correct? Newest Cmdstan versions are well tested only with Rtools35. Please upgrade if you are not using those.

Other options to check on Windows are usually:

  • there are no spaces in Cmdstan or model paths
  • do you have proper permissions in the target folder (try placing cmdstan in documents or desktop)
1 Like

Thank you very much for your reply. I did not use git - I downloaded and extracted the tar/gz files and followed the instructions in the cmd-stan guide.
I also tried - as a workaround - to install cmd stan via python - but then I got a huge (almost never ending) screen of messages and an error.

Thank you for your suggestions - I relocated the CMD installation to a different folder - but this did not solve my problem. (Btw: The rtools version was indeed a typo - sorry. I use the newest version that is currently recommended). If it helps in diagnosing the problem, I should also mention that there are lines in the error output (I won’t paste the whole output - its huge) like this:

"warning: enum constant in boolean context [-Wint-in-bool-context]
86 | MayLinearVectorize = bool(MightVectorize) && MayLinearize && DstHasDirectAccess"

wherein the bold part is highlighted in purple

I got some minor changes when first calling make stan-update. But now the following message (along with others) appears:

src/cmdstan/stanc.cpp:1:0: sorry, unimplemented: 64-bit mode not compiled in

Can you please run g++ --version? Also make sure to run mingw32-make clean-all before running build

src/cmdstan/stanc.cpp:1:0: sorry, unimplemented: 64-bit mode not compiled in

I have never seen this one, sorry.

Thanks.

The g++ --version reults in:

“g++ (i686-posix-dwarf, Built by MinGW-W64 project) 4.9.3
Copyright © 2015 Free Software Foundation, Inc.”

and even after incorporating “clean-all” I get a large output with content like:
“cc1plus.exe: sorry, unimplemented: 64-bit mode not compiled in
”

Do you have any further ideas what could resolve this problem?

do you have any RStan installs?

did you use the CmdStanPy ‘install_cmdstan’ script or?

Where is the m64 coming from? Can you remove that somehow? Check your Makevars I guess (not sure where that is on Windows)?

Yes, I have installed rstan some time ago.

With respect to cmdstanpy:
I used the instructions given in:

https://cmdstanpy.readthedocs.io/en/latest/getting_started.html

and after running install_cmdstan I get the message
unpacked download cmdstan 2.22.1 binaries
WARNING:cmdstanpy:CmdStan installation failed

found this on StackOverflow -

When running mingw-64-install.exe , you have to choose the x86_64 architecture on the settings screen. With this architecture, 64-bit is also the default target. If you run g++ -v , you should get something like:

C:\>g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=C:/Program\ Files/mingw-w64/x86_64-5.3.0-posix-seh-rt_v4-rev0/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/5.3.0/lto-wrapper.exe
Target: x86_64-w64-mingw32

what does g++ -v say on your machine, specifically, Target: ?

I have installed CmdStan recently on Windows 10 and struggled my way through multiple discussions forums to finally install it. I am a not an expert but I hope I can help with what I did during installation.

1.The output of g++ --version you shared doesn’t seem the same as mentioned by Mitzi in the comment above. You may want to check your installation of mingw-64-install.exe.
2. I uninstalled MingW completely then I ran the installer mingw-64-install.exe. I choose x86_64 architecture and posix in the Threads options.
3. Add bind directory of MinGW-W64 to the Environment Variables. For me it looks something like C:\mingw-w64\mingw64\bin (The name might be different for you depending on which folder or directory you install in)

The tutorial I referred for installation might come in handy (https://cpp.tutorials24x7.com/blog/how-to-install-mingw-on-windows)

PS : @bbbales2 @mitzimorris please don’t down vote me. I am a beginner myself and I am happy to remove the comment if it doesn’t seem correct according to you

4 Likes

Dont be discouraged from helping. If something worked for you, feel free to post.

Yeah, this seems to be a problem with environment variables and mingw.

I tend to just advise people to install RTools 3.5 (Rtools 4.0 support hasnt been properly tested yet) and uninstall any separate minGW installs. Rtools comes with everything you need for Stan/Cmdstan and we know it works on a clean system every time.

Anyone reading this in the future: If you need MinGW for some other project you are working on, see advice from @sam_learner. If not, uninstalling mingw and installing RTools is usually the easier route to cmdstan hapiness.

1 Like

@sam_learner yeah what @rok_cesnovar said. Thanks for posting what you did!

1 Like

I think I had this problem before. I installed RTools 3.5 and then had to check that everything in PATH is correct until I got the output for g++ -v that @mitzimorris quoted (Target: x86_64-w64-mingw32).

2 Likes

quite the opposite! thanks so much for working through this and sharing your findings!

2 Likes