CmdStan Bernoulli Example Compiling but Not Running (Windows 10, CmdStan 2.26.1)

Hi!

The example Stan model with CmdStan located in the examples/bernoulli directory is compiling but not running . The system used is running Windows 10 and CmdStan 2.26.1.

There are no errors when building the Stan model into an executable using mingw32-make:

--- Translating Stan model to C++ code ---
bin/stanc.exe  --o=examples/bernoulli/bernoulli.hpp examples/bernoulli/bernoulli.stan

--- Compiling, linking C++ code ---
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 -Wno-int-in-bool-context -Wno-attributes -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2019_U8/include   -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.72.0 -I stan/lib/stan_math/lib/sundials_5.6.1/include  -D_USE_MATH_DEFINES  -DBOOST_DISABLE_ASSERTS         -c  -x c++ -o examples/bernoulli/bernoulli.o examples/bernoulli/bernoulli.hpp
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 -Wno-int-in-bool-context -Wno-attributes -Wno-ignored-attributes      -I stan/lib/stan_math/lib/tbb_2019_U8/include   -O3 -I src -I stan/src -I lib/rapidjson_1.1.0/ -I lib/CLI11-1.9.1/ -I stan/lib/stan_math/ -I stan/lib/stan_math/lib/eigen_3.3.9 -I stan/lib/stan_math/lib/boost_1.72.0 -I stan/lib/stan_math/lib/sundials_5.6.1/include  -D_USE_MATH_DEFINES  -DBOOST_DISABLE_ASSERTS               -Wl,-L,"C:/Users/xxx/.cmdstan/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb" -Wl,-rpath,"C:/Users/xxx/.cmdstan/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb"      examples/bernoulli/bernoulli.o src/cmdstan/main.o  -static-libgcc -static-libstdc++       stan/lib/stan_math/lib/sundials_5.6.1/lib/libsundials_nvecserial.a stan/lib/stan_math/lib/sundials_5.6.1/lib/libsundials_cvodes.a stan/lib/stan_math/lib/sundials_5.6.1/lib/libsundials_idas.a stan/lib/stan_math/lib/sundials_5.6.1/lib/libsundials_kinsol.a  stan/lib/stan_math/lib/tbb/tbb.dll -o examples/bernoulli/bernoulli.exe
rm -f examples/bernoulli/bernoulli.o
Intel TBB is not in PATH.
Consider calling
mingw32-make install-tbb
to avoid copying Intel TBB library files.
'stan/lib/stan_math/lib/tbb/tbb.dll' -> 'examples/bernoulli/tbb.dll'

However, the following error appears when trying to run basic MCMC sampling on the executable:

bernoulli.exe sample data bernoulli.data.json

The procedure entry point _ZNSt11range_errorC1EPKc could not be located in the dynamic link library C:\Users\xxx.cmdstan\cmdstan-2.26.1\examples\bernoulli\tbb.dll

When building the executable, Stan gave a warning about the Intel TBB not being in the PATH, so I tried setting the PATH variable both manually and using the install-tbb batch script provided, but it still does not work. I also tried re-installing CmdStan twice: once by installing it from the latest binaries on GitHub and another time by installing it through CmdStanPy (which is how I plan on using CmdStan). I also tried updating the Visual C++ Redistributable for Windows which was shown online to solve the entry point issue for DLLs.

I tried searching through the forums, but I am unable to find anything comparable to the issue I’m facing. Can someone please help me resolve this.

hi, I checked the CmdStan installation manual - 1 CmdStan Installation | CmdStan User’s Guide. - it says:

Windows only: CmdStan requires that the Intel TBB library, which is built by the above command, can be found by the Windows system. This requires that the directory <cmdstan-home>/stan/lib/stan_math/lib/tbb is part of the PATH environment variable. To permanently make this setting for the current user, you may execute:

> mingw32-make install-tbb

After changing the PATH environment variable, you must open an new shell in order to these setting to take effect. (This is not necessary on Mac and Linux systems because they can use the absolute path to the Intel TBB library when linking into Stan programs.)

so maybe do a mingw32-make clean-all then the above command, then rebuild?

Hi!

Thanks for your response. I had tried to run mingw32-make clean all and then re-build before, but I ran the install-tbb command after doing that. I tried running the commands in the particular sequence you mentioned, but I still get the same error with the procedure entry point not being found in the DLL.

Also, there was a small typo in the install-tbb batch file I had to fix before the command would run successfully. I had to add quotation marks around the path in the setx command:

setx Path "%~dp0stan\lib\stan_math\lib\tbb;%OLD_SYSTEM_PATH%"

Is there any way to debug and pinpoint the source of the error?

What did you set in the PATH variable? Based on the error messages it should be

C:/Users/xxx.cmdstan/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb

Yes, the PATH variable includes C:/Users/xxx/.cmdstan/cmdstan-2.26.1/stan/lib/stan_math/lib/tbb. I tried setting it in both the user’s PATH variable and the system-wide PATH variable.

Fixed it by installing CmdStan on a different Windows 10 system which didn’t have many applications installed and had no C++ compilers prior to installing CmdStan. The current system I’m using has several C++ compilers from RTools, Strawberry Perl, and Visual Studio, which could have been the issue. The typo in install-tbb with the setx command still persists on the second system though, so it might be helpful to get this fixed for other users.

3 Likes