Building Stan Library

Hi,

Trying to run tests for the stan-dev/stan library, as a test. stan-dev/math builds fine.

In C++, usually this means there’s no include in the header (math library we have prim.hpp, whatever) stan-dev/stan, no headers (header files, but you see what I’m saying). What am I missing?

make src/test/unit/services/experimental/advi/defaults_tes t g++ src/test/unit/services/experimental/advi/defaults_test.cpp -o src/test/unit/services/experimental/advi/defaults_test src/test/unit/services/experimental/advi/defaults_test.cpp:1:10: fatal error: stan/services/experimental/advi/defaults.hpp: No such file or directory 1 | #include <stan/services/experimental/advi/defaults.hpp> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated. make: *** [<builtin>: src/test/unit/services/experimental/advi/defaults_test] Error 1

Makes me look stupid, but asking a stupid question after an hour or two makes everything run faster.

I’ve downloaded and built stanc3, but this is only for parsing the language, and then generating the C++ executable, I think.

Figured it out, just cd to stan and type make, and all of the instructions are there. sweet.

alright… so I’m just compiling tests so I can get set up.

I’m running make src/test/unit/services/optimize/lbfgs_test

And it’s missing some of the includes, but they exist. In the math library, and what’s usually done in C++/C is there’s a header file, which includes all of the files, so you have one higher level include (i.e. prim.hpp), is there a reason we’re not doing this?

This is after I’ve run test-headers successfully.

And then I’m running this, without error: ‘make src/stan/optimization/bfgs.hpp-test’. Usually in stan/math it generates an executable which you can run with ./runTests.py, but it’s not happening here.

make src/stan/optimization/bfgs.hpp-test g++ -std=c++17 -pthread -D_REENTRANT -Wno-sign-compare -Wno-ignored-attributes -Wno-class-memaccess -I lib/stan_math/lib/tbb_2020.3/include -O3 -I src -I ./src/ -I lib/rapidjson_1.1.0/ -I lib/stan_math/ -I lib/stan_math/lib/eigen_3.4.0 -I lib/stan_math/lib/boost_1.87.0 -I lib/stan_math/lib/sundials_6.1.1/include -I lib/stan_math/lib/sundials_6.1.1/src/sundials -DBOOST_DISABLE_ASSERTS -c -O0 -include src/stan/optimization/bfgs.hpp test/dummy.cpp -o /dev/null

The -o flag generates an executable with a specified name. We’re just dumping it in null?

I have to be missing a few things, there’s clearly tests here.

I was able to

and then I put stan/math under stan/src/stan/lib/math. I’ve checked to see all lib versions and compilers are all recent or correct.

When I compile the make test-headers, it works fine. When I add the math library, it gives me some issues.

I think I just put it in the wrong spot, math library compiles and run tests fine.

When I add the math library, and run make test-headersI get something like this, after

g++ -std=c++17 -pthread -D_REENTRANT -Wno-sign-compare -Wno-ignored-attributes -Wno-class-memaccess -I lib/stan_math/lib/tbb_2020.3/include -O3 -I src -I ./src/ -I lib/rapidjson_1.1.0/ -I lib/stan_math/ -I lib/stan_math/lib/eigen_3.4.0 -I lib/stan_math/lib/boost_1.87.0 -I lib/stan_math/lib/sundials_6.1.1/include -I lib/stan_math/lib/sundials_6.1.1/src/sundials -DBOOST_DISABLE_ASSERTS -c -O0 -include src/stan/math/lib/boost_1.87.0/boost/accumulators/numeric/detail/function_n.hpp test/dummy.cpp -o /dev/null In file included from <command-line>: ./src/stan/math/lib/boost_1.87.0/boost/accumulators/numeric/detail/function_n.hpp:54:1error: macro "BOOST_PP_SEQ_ELEM_III" requires 2 arguments, but only 1 given 54 | struct function_name

This runs, and compiles fine:

i.e. make src/stan/optimization/bfgs.hpp-test

My goal is just to be able to run unit tests:

make src/test/unit/optimization/bfgs_test

But this is saying the bfgs.hpp does not exist, from the includes… am I missing something?