Unable to compile model using cmdstan on linux

I’m unable to compile the example Bernoulli model on linux server, I can bulid CmdStan 2.31.0, but Bernoulli crashes at the linking stage:
My code and error:

(my_stan) [shpli3@login02 cmdstan]$ make examples/bernoulli/bernoulli

--- Compiling, linking C++ code ---
/data/home/shpli3/miniconda3/envs/my_stan/bin/x86_64-conda-linux-gnu-c++ -fvisibility-inlines-hidden -std=c++17 -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /data/home/shpli3/miniconda3/envs/my_stan/include -std=c++1y -D_REENTRANT -Wno-sign-compare -Wno-ignored-attributes      -I /data/home/shpli3/miniconda3/envs/my_stan/include/    -O3 -I src -I stan/src -I stan/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.78.0 -I stan/lib/stan_math/lib/sundials_6.1.1/include -I stan/lib/stan_math/lib/sundials_6.1.1/src/sundials -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -isystem /data/home/shpli3/miniconda3/envs/my_stan/include    -DBOOST_DISABLE_ASSERTS   -DTBB_INTERFACE_NEW  -DTBB_INTERFACE_NEW     -c  -x c++ -o examples/bernoulli/bernoulli.o examples/bernoulli/bernoulli.hpp
In file included from stan/lib/stan_math/stan/math/prim/core/init_threadpool_tbb.hpp:17,
                 from stan/lib/stan_math/stan/math/prim/core.hpp:4,
                 from stan/lib/stan_math/stan/math/rev/core/Eigen_NumTraits.hpp:5,
                 from stan/lib/stan_math/stan/math/rev/core/typedefs.hpp:7,
                 from stan/lib/stan_math/stan/math/rev/core/chainable_object.hpp:6,
                 from stan/lib/stan_math/stan/math/rev/core.hpp:10,
                 from stan/lib/stan_math/stan/math/rev.hpp:8,
                 from stan/lib/stan_math/stan/math.hpp:19,
                 from stan/src/stan/model/model_header.hpp:4,
                 from examples/bernoulli/bernoulli.hpp:3:
/data/compiler/intel2017u5/compilers_and_libraries_2017.5.239/linux/tbb/include/tbb/global_control.h:25:2: error: #error Set TBB_PREVIEW_GLOBAL_CONTROL before including global_control.h
   25 | #error Set TBB_PREVIEW_GLOBAL_CONTROL before including global_control.h
      |  ^~~~~
In file included from stan/lib/stan_math/stan/math/rev/functor.hpp:29,
                 from stan/lib/stan_math/stan/math/rev.hpp:11,
                 from stan/lib/stan_math/stan/math.hpp:19,
                 from stan/src/stan/model/model_header.hpp:4,
                 from examples/bernoulli/bernoulli.hpp:3:
stan/lib/stan_math/stan/math/rev/functor/reduce_sum.hpp: In member function 'stan::math::var stan::math::internal::reduce_sum_impl<ReduceFunction, typename std::enable_if<stan::is_var<typename std::decay<_Tp2>::type, void>::value, void>::type, ReturnType, Vec, Args ...>::operator()(Vec&&, bool, int, std::ostream*, Args&& ...) const':
stan/lib/stan_math/stan/math/rev/functor/reduce_sum.hpp:257:27: error: 'isolate' is not a member of 'tbb::this_task_arena'
  257 |     tbb::this_task_arena::isolate([&] {
      |                           ^~~~~~~
make: *** [make/program:58: examples/bernoulli/bernoulli] Error 1

That’s my system and platform information:

  • Operating System:Platform: x86_64-pc-linux-gnu (64-bit)
    Running under: Red Hat Enterprise Linux Server 7.6 (Maipo)
  • CmdStan Version: 2.31.0
  • g++ version: g++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)
  • make version: GNU Make 4.3 Built for x86_64-conda-linux-gnu

I wonder if my g++ and make version are too old to lead to this error. Anyone can give me some advice, Thx!

I believe the oldest compiler we regularly use is 4.9.1, so it’s possible your version is too old, but it also looks like you’re using a compiler from conda (most likely conda is setting the $CXX environment variable):

Thanks for your answer!